Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

精度问题 #59

Open
xxx2974 opened this issue Nov 12, 2018 · 3 comments
Open

精度问题 #59

xxx2974 opened this issue Nov 12, 2018 · 3 comments

Comments

@xxx2974
Copy link

xxx2974 commented Nov 12, 2018

有一个问题请教,直接训练和测试时结果是对的,但是用自己保存的训练的模型拿来测试,会提示一些问题,精度也非常低?
细节如下:

Keys not found in source state_dict:
base.layer1.2.bn2.weight
base.layer3.0.conv2.weight
base.layer3.0.downsample.1.weight
base.layer1.1.conv2.weight
base.layer2.1.conv2.weight
base.layer1.0.conv1.weight
base.layer1.0.bn2.running_mean
base.layer3.4.conv1.weight
base.layer2.0.conv3.weight
base.layer4.2.bn3.running_mean
base.layer3.4.bn1.bias
base.layer4.1.conv2.weight
base.layer4.0.conv3.weight
base.layer3.4.bn3.bias
base.layer1.0.bn1.running_var
base.layer4.0.bn3.weight
base.layer3.5.bn3.running_mean
base.layer1.2.bn1.bias
base.layer2.2.bn2.running_var
base.layer2.2.bn3.bias
base.layer2.1.bn2.bias
base.layer2.0.bn3.running_var
base.layer2.3.bn1.running_mean
local_bn.running_var
base.layer4.2.bn1.bias
base.layer2.2.conv2.weight
base.bn1.bias
base.layer3.3.bn1.bias
fc.weight
base.layer3.1.bn2.running_mean
base.layer3.1.bn2.weight
base.layer4.1.bn1.bias
base.layer2.2.bn2.bias
base.layer3.4.bn1.running_mean
base.layer1.0.downsample.1.bias
base.layer2.2.bn1.running_var
base.layer1.1.bn3.running_var
base.layer1.0.downsample.0.weight
base.layer4.0.bn3.running_mean
base.layer3.5.bn1.running_mean
base.layer2.2.bn1.running_mean
base.layer1.2.bn1.running_mean
base.layer1.1.bn3.running_mean
base.layer1.2.bn2.running_mean
base.layer2.2.conv1.weight
base.layer4.0.bn2.running_var
base.layer1.2.bn3.bias
base.layer4.0.downsample.0.weight
base.layer1.1.conv3.weight
base.layer1.0.conv3.weight
base.layer1.0.bn3.bias
base.layer1.2.bn1.running_var
base.layer1.1.bn2.bias
base.layer3.2.bn3.running_var
base.layer2.0.bn2.weight
base.layer3.0.downsample.1.running_var
base.layer3.4.conv2.weight
base.layer2.3.conv1.weight
base.layer3.3.conv3.weight
base.layer3.0.bn1.bias
base.layer3.0.downsample.1.running_mean
base.layer2.2.bn3.weight
base.bn1.weight
base.layer2.1.conv3.weight
base.layer3.5.bn2.bias
base.layer2.2.bn2.running_mean
base.layer1.0.bn2.weight
base.layer3.4.bn2.running_mean
base.layer1.0.bn1.running_mean
base.layer2.0.downsample.0.weight
base.layer3.4.bn1.running_var
base.layer1.2.conv1.weight
base.layer3.4.bn2.running_var
base.layer2.0.conv1.weight
base.layer1.1.bn2.running_mean
base.layer2.0.bn1.weight
base.layer3.0.downsample.1.bias
base.layer1.1.bn2.running_var
base.layer3.2.conv1.weight
base.layer1.0.bn2.running_var
base.layer3.5.bn1.bias
base.layer2.0.downsample.1.running_var
base.layer1.1.conv1.weight
base.layer2.1.bn1.running_var
base.layer1.2.conv3.weight
base.layer2.2.bn1.bias
base.layer3.3.bn2.running_var
base.layer4.0.conv2.weight
base.layer4.2.bn2.bias
base.layer2.3.conv2.weight
base.layer3.5.bn3.bias
base.layer3.0.bn2.weight
base.layer3.4.conv3.weight
base.layer2.1.bn3.running_mean
fc.bias
。。。
Keys not found in destination state_dict:
state_dicts
ep
scores
Loaded model weights from /home/xiaozhenzhen/data/AlignedReID-Re-Production-Pytorch/exp/train/market1501/not_nf_not_ohs_ gm_0.3_lm_0.3_glw_1_llw_0_idlw_0_lr_0.0002_exp_decay_at_151_total_300/run1/ckpt.pth

=========> Test on dataset: market1501 <=========

Extracting feature...
1000/1000 batches done, +1.88s, total 99.11s
Done, 99.32s
Computing global distance...
Done, 0.91s
Computing scores for Global Distance...
[mAP: 2.09%], [cmc1: 8.31%], [cmc5: 16.83%], [cmc10: 22.57%]
Done, 13.64s
Re-ranking...
Done, 64.49s
Computing scores for re-ranked Global Distance...
[mAP: 3.24%], [cmc1: 9.98%], [cmc5: 17.87%], [cmc10: 22.09%]
Done, 14.04s

@huanghoujing
Copy link
Owner

你好,看起来是模型没有load正确,那些权重都没有复制进去。你ckpt.pth这个文件应该直接放在exp_dir底下就行,不要传递给model_weight_file这个参数。关于ckpt.pthmodel_weight_file的区别,可以参考我这个回答

@xxx2974
Copy link
Author

xxx2974 commented Nov 25, 2018

好的,谢谢,已经明白两种不同的load方式,非常感谢!

@jszgz
Copy link

jszgz commented Aug 19, 2019

你好,为什么我保存的ckpt.pth有500多MB,而你提供的才几十MB。此外,我使用测试的参数按你说的方法进行测试,还会报错。

Traceback (most recent call last):
File "script/experiment/train.py", line 632, in
main()
File "script/experiment/train.py", line 389, in main
test(load_model_weight=True)
File "script/experiment/train.py", line 376, in test
load_ckpt(modules_optims, cfg.ckpt_file)
File "./aligned_reid/utils/utils.py", line 239, in load_ckpt
m.load_state_dict(sd)
File "/usr/local/anaconda3/envs/wtalignedreid/lib/python2.7/site-packages/torch/optim/optimizer.py", line 84, in load_state_dict
saved_groups = state_dict['param_groups']
KeyError: 'param_groups'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants