Error(s) in loading state_dict for Net: Missing key(s) in state_dict
See original GitHub issueHi, thanks for your codes. I trained a checkpoint model named carn_m_180000.pth, but when I testing it by sample.py, I got following error, could you give me some suggestions?
$ python3 carn/sample.py --model=carn_m --ckpt_path=./checkpoint/carn_m/carn_m_180000.pth --sample_dir=./sample/
using this model
{
"ckpt_path": "./checkpoint/carn_m/carn_m_180000.pth",
"cuda": false,
"group": 1,
"model": "carn_m",
"sample_dir": "./sample/",
"scale": 2,
"shave": 20,
"test_data_dir": "dataset/DIV2K_valid_LR_bicubic/X2"
}
Traceback (most recent call last):
File "carn/sample.py", line 122, in <module>
main(cfg)
File "carn/sample.py", line 110, in main
net.load_state_dict(new_state_dict)
File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 719, in load_state_dict
self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Net:
Missing key(s) in state_dict: "upsample.up2.body.0.bias", "upsample.up2.body.0.weight", "upsample.up3.body.0.bias", "upsample.up3.body.0.weight", "upsample.up4.body.0.bias", "upsample.up4.body.0.weight", "upsample.up4.body.3.bias", "upsample.up4.body.3.weight".
Unexpected key(s) in state_dict: "upsample.up.body.0.weight", "upsample.up.body.0.bias".
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
RuntimeError: Error(s) in loading state_dict for Net #100 - GitHub
Hi Mr. Zhang: When I test pre-trained model on MINC-2500 using: python main.py --dataset minc --model deepten --nclass 23 --resume ...
Read more >RuntimeError: Error(s) in loading state_dict for Generator
You saved the weights with the wrong names. That is you saved the generator's weights as dcgan_d.pth and likewise, saved the descriminator's ...
Read more >Missing keys & unexpected keys in state_dict when loading ...
After that I would like to infer some images using my model, it fails with the follow error: RuntimeError: Error(s) in loading state_dict...
Read more >RuntimeError: Error(s) in loading state_dict for DynamicUnet
Here, I aim to load the model and weights to run inference with new ... in loading state_dict for DynamicUnet: Missing key(s) in...
Read more >RuntimeError: Error in loading state_dict for SSD: Unexpected ...
This is the complete error: RuntimeError: Error(s) in loading state_dict for SSD: Unexpected key(s) in state_dict: “base_net.1.0.weight”, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@wydwww https://github.com/nmhkahn/CARN-pytorch/blob/160a4bc444dd0acfa4bbe93e5f8e45e9cd551c22/carn/sample.py#L96 It missed a parameter
scale=cfg.scale
. Andmulti-scale
should beFalse
if you did not use cfg.multi_scale@Ji-qing Which parameter is missed? Thanks