KoichiYasuoka commited on
Commit
2ea3689
1 Parent(s): 51bb6d2

with torch.nograd

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