hiyoung123 / SoftMaskedBert

Soft-Masked Bert 复现论文:https://arxiv.org/pdf/2005.07421.pdf
254 stars 47 forks source link

loss.backward(retain_graph=True) 报错 #16

Open mrb957600057 opened 4 years ago

mrb957600057 commented 4 years ago

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [768]] is at version 3; expected version 2 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

请问您有遇到这个问题吗?

mrb957600057 commented 4 years ago

版本问题,切换到1.4没问题

lmw0320 commented 3 years ago

版本问题,切换到1.4没问题

请教下,如果还是保持1.5的版本,要修改哪里的代码呢?

baojunshan commented 3 years ago

版本问题,切换到1.4没问题

请教下,如果还是保持1.5的版本,要修改哪里的代码呢?

https://github.com/hiyoung123/SoftMaskedBert/blob/25b62c735ae6b01457f723a880bf30102223d87a/model/soft_masked_bert.py#L27

改成

self.mask_e = self.embedding(mask_token_id).detach()