XuhanLiu / DrugEx

Deep learning toolkit for Drug Design with Pareto-based Multi-Objective optimization in Polypharmacology
MIT License
196 stars 67 forks source link

Error using designer with the default agent #6

Open martin-sicho opened 4 years ago

martin-sicho commented 4 years ago

I can use the code in the repo to train my own DrugEx agent model and in that case the designer.py script works just as it should when I point it to the agent I created.

However, I ran into a problem when I tried to use the data/agent.pkg file that was already committed to the repository (62423a71f550396be4f59d2747f05d42c690329a). I got the following error:

Traceback (most recent call last):
  File "/home/sichom/projects/DrugEx/designer.py", line 52, in <module>
    generate(agent_path, out_path, num=pop_size)
  File "/home/sichom/projects/DrugEx/designer.py", line 26, in generate
    agent.load_state_dict(torch.load(agent_path))
  File "/home/sichom/anaconda/envs/drugex/lib/python3.5/site-packages/torch/nn/modules/module.py", line 769, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Generator:
    Missing key(s) in state_dict: "embed.weight", "rnn.weight_ih_l0", "rnn.bias_hh_l2", "rnn.weight_hh_l2", "rnn.bias_hh_l0", "rnn.bias_ih_l1", "rnn.bias_hh_l1", "rnn.bias_ih_l0", "rnn.bias_ih_l2", "rnn.weight_ih_l1", "rnn.weight_ih_l2", "rnn.weight_hh_l1", "rnn.weight_hh_l0". 
    Unexpected key(s) in state_dict: "embedding.weight", "gru_1.weight_ih", "gru_1.weight_hh", "gru_1.bias_ih", "gru_1.bias_hh", "gru_2.weight_ih", "gru_2.weight_hh", "gru_2.bias_ih", "gru_2.bias_hh", "gru_3.weight_ih", "gru_3.weight_hh", "gru_3.bias_ih", "gru_3.bias_hh". 
    size mismatch for linear.bias: copying a param with shape torch.Size([58]) from checkpoint, the shape in current model is torch.Size([50]).
    size mismatch for linear.weight: copying a param with shape torch.Size([58, 512]) from checkpoint, the shape in current model is torch.Size([50, 512]).

Could it be because the repository version of the data/voc.txt does not correspond to the data/voc.txt that was used to create this data/agent.pkg perhaps?

I think it would be nice to have the files under data/ documented in the README.md so it is clear where this data/agent.pkg came from and what it can be used for (is it the one trained for the purpose of the publication or something else?)

Many thanks for any info.