I was training a Neural Turing Machine with memory bias and go the following error when loading the model. It has to do with the “mem_bias”, but even the error message says that the sizes torch.Size([128, 20]) seem to match.
Please note the variable was saved as a buffer, but other variables were too and the load seems to have worked for them.
“self.register_buffer(‘mem_bias’, Variable(torch.Tensor(N, M)))”
It was all run on CPU.
Error message:
Traceback (most recent call last):
File “C:\Users\frede\Anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 514, in load_state_dict
own_state[name].copy_(param)
File “C:\Users\frede\Anaconda3\lib\site-packages\torch\autograd\variable.py”, line 67, in getattr
return object.getattribute(self, name)
AttributeError: ‘Variable’ object has no attribute ‘copy_’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:/Users/frede/Documents/GitHub/Homework3/Evaluate_NTM_LSTM.py”, line 56, in 
loadNTM(model_NTM_LSTM, files_NTM_LSTM)
File “C:\Users\frede\Documents\GitHub\Homework3\train.py”, line 89, in loadNTM
model.net.load_state_dict(state_dict)
File “C:\Users\frede\Anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 519, in load_state_dict
.format(name, own_state[name].size(), param.size()))
RuntimeError: While copying the parameter named ntm.memory.mem_bias, whose dimensions in the model are torch.Size([128, 20]) and whose dimensions in the checkpoint are torch.Size([128, 20]).
Any idea about what it can be?