hiyoung123 / SoftMaskedBert

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

关于train.py的问题 #4

Closed qq596588073 closed 4 years ago

qq596588073 commented 4 years ago

您好,感谢您复现论文的代码开源,我将训练所需要的数据都准备完毕,但在train.py时一直出现如下报错: File "train.py", line 182, in trainer.train(train_data_loader, e) File "train.py", line 33, in train return self.iteration(epoch, train_data) File "train.py", line 79, in iteration loss.backward(retain_graph=True) File "/usr/local/lib/python3.6/dist-packages/torch/tensor.py", line 198, in backward torch.autograd.backward(self, gradient, retain_graph, create_graph) File "/usr/local/lib/python3.6/dist-packages/torch/autograd/init.py", line 100, in backward allow_unreachable=True) # allow_unreachable flag 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). 请问您能提供一些解决办法?十分感谢!

lscm2019 commented 4 years ago

应该是torch版本问题 我之前用torch 1.5.1 也有同样的问题 安装 torch 1.4.0 就可以训练了 pip3 uninstall torch pip3 install torch==1.4.0

qq596588073 commented 4 years ago

应该是torch版本问题 我之前用torch 1.5.1 也有同样的问题 安装 torch 1.4.0 就可以训练了 pip3 uninstall torch pip3 install torch==1.4.0

感谢您的解答,问题解决了