aks2203 / deep-thinking

A centralized place for deep thinking code and experiments
MIT License
77 stars 15 forks source link

Error loading model from checkpoint #5

Closed Maosef closed 2 years ago

Maosef commented 3 years ago

How I found it: I was testing a modified 2D model in a jupyter notebook. load_model_from_checkpoint brought up the error:

actual error: RuntimeError: Error(s) in loading state_dict for DTNet:
    Missing key(s) in state_dict: "projection.0.weight", "recur_block.0.0.conv1.weight", "recur_block.0.0.conv2.weight", "recur_block.0.1.conv1.weight", "recur_block.0.1.conv2.weight", "head.0.weight", "head.2.weight", "head.4.weight". 
    Unexpected key(s) in state_dict: "module.projection.0.weight", "module.recur_block.0.0.conv1.weight", "module.recur_block.0.0.conv2.weight", "module.recur_block.0.1.conv1.weight", "module.recur_block.0.1.conv2.weight", "module.head.0.weight", "module.head.2.weight", "module.head.4.weight".

We looked into it, and believe this is relevant: https://discuss.pytorch.org/t/missing-keys-unexpected-keys-in-state-dict-when-loading-self-trained-model/22379 We resolved it by modifying load_model_from_checkpoint. This may be an issue with the other models.