Closed xml94 closed 1 week ago
I found the non-error by changing a line of code in iern_model.py as follows:
Hi, @xml94. Thanks for your interest in this project.
I feel the issue might be caused by the PyTorch version. As mentioned in the README, this project worked fine on PyTorch version 1.4 when it was built, but it might have some issues when working with the current, newer version.
Thank you for your wonderful work.
I got an gradient updating error as follows, could you please help me to figure it out?
Traceback (most recent call last): File "train.py", line 96, in
model.optimize_parameters() # calculate loss functions, get gradients, update network weights
File "/home/oem/Mingle/casual_emotion/models/iern_model.py", line 166, in optimize_parameters
self.backward_Cls()
File "/home/oem/Mingle/casual_emotion/models/iern_model.py", line 146, in backward_Cls
self.loss_Cls.backward()
File "/home/oem/anaconda3/envs/Mingle/lib/python3.8/site-packages/torch/_tensor.py", line 488, in backward
torch.autograd.backward(
File "/home/oem/anaconda3/envs/Mingle/lib/python3.8/site-packages/torch/autograd/init.py", line 197, in backward
Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [512]] is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).