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

when I load the pretrained_model, the shape of weights always mismatch #31

Open
garyliu0816 opened this issue Apr 17, 2019 · 2 comments

Comments

@garyliu0816
Copy link

Traceback (most recent call last):
File "train.py", line 184, in
main(parser.parse_args())
File "train.py", line 41, in main
model = models.create(args.net, pretrained=True, dim=args.dim)
File "D:\ProgramData\pyProjects\Pytorch-Deep-metric\models_init_.py", line 22, in create
return __factory[name](*args, **kwargs)
File "D:\ProgramData\pyProjects\Pytorch-Deep-metric\models\BN_Inception.py", line 521, in BN_Inception
model.load_state_dict(model_dict)
File "D:\Program Files\Anaconda3\envs\pytorch1\lib\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 BNInception:
size mismatch for conv1_7x7_s2_bn.weight: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for conv1_7x7_s2_bn.bias: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for conv1_7x7_s2_bn.running_mean: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).

How to solve this problem?

@usamieiji
Copy link

I got the same problem. Should I modify 'BN_Inception.py' to match the pre-trained model?

@usamieiji
Copy link

I tried this pre-trained model
http://data.lip6.fr/cadene/pretrainedmodels/bn_inception-52deb4733.pth
It works without modifying 'BN_Inception.py'

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

2 participants