How can I load the weights of an LSTM module to an LSTMCell?
I tried : self.lstm_cell.load_state_dict(self.lstm.state_dict)
but I get the following error:
self.lstm_cell.load_state_dict(self.lstm.state_dict)
File "/home/luca/anaconda3/envs/rdkit_env/lib/python3.7/site-packages/torch/nn/modules/module.py", line 812, in load_state_dict
state_dict = state_dict.copy()
AttributeError: 'function' object has no attribute 'copy'
You should probably take another look at the Doc. I remembered state_dict is not a attribute nor a property: it is a function, as described in the traceback. So, you should use state_dict = lstm.state_dict()
Also, say u have 2 lstm: A, B. These two have different structures. I guess what u r doing is using the weights from A to initialize B, which of course won’t work.