KoichiYasuoka commited on
Commit
31361cd
1 Parent(s): 9c7baa9

with torch.nograd

Browse files
Files changed (1) hide show
  1. README.md +3 -2
README.md CHANGED
@@ -73,8 +73,9 @@ class TransformersUD(object):
73
  q=[self.tokenizer.cls_token_id]+t+[self.tokenizer.sep_token_id]
74
  c.append([q]+v[0:i]+[[self.tokenizer.mask_token_id]]+v[i+1:]+[[q[-1]]])
75
  b=[[len(sum(x[0:j+1],[])) for j in range(len(x))] for x in c]
76
- d=self.model(input_ids=torch.tensor([sum(x,[]) for x in c]),
77
- token_type_ids=torch.tensor([[0]*x[0]+[1]*(x[-1]-x[0]) for x in b]))
 
78
  s,e=d.start_logits.tolist(),d.end_logits.tolist()
79
  for i in range(n):
80
  for j in range(n):
 
73
  q=[self.tokenizer.cls_token_id]+t+[self.tokenizer.sep_token_id]
74
  c.append([q]+v[0:i]+[[self.tokenizer.mask_token_id]]+v[i+1:]+[[q[-1]]])
75
  b=[[len(sum(x[0:j+1],[])) for j in range(len(x))] for x in c]
76
+ with torch.no_grad():
77
+ d=self.model(input_ids=torch.tensor([sum(x,[]) for x in c]),
78
+ token_type_ids=torch.tensor([[0]*x[0]+[1]*(x[-1]-x[0]) for x in b]))
79
  s,e=d.start_logits.tolist(),d.end_logits.tolist()
80
  for i in range(n):
81
  for j in range(n):