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

Parameter mismatch when loading VGG ImageNet pre-trained weights #93

Open
JuiChang opened this issue Nov 27, 2020 · 2 comments
Open

Parameter mismatch when loading VGG ImageNet pre-trained weights #93

JuiChang opened this issue Nov 27, 2020 · 2 comments

Comments

@JuiChang
Copy link

JuiChang commented Nov 27, 2020

First of all, thanks for sharing the project!

As in the previous issue, the given VGG ImageNet pre-trained weights cannot match the model architecture in ./model/deeplab_vgg.py
I got the same error message as in the issue:
RuntimeError: Error(s) in loading state_dict for DeeplabVGG: Unexpected key(s) in state_dict: "0.weight", "0.bias", "2.weight", "2.bias", "5.weight", "5.bias", "7.weight", "7.bias", "10.weight", "10.bias", "12.weight", "12.bias", "14.weight", "14.bias", "17.weight", "17.bias", "19.weight", "19.bias", "21.weight", "21.bias", "24.weight", "24.bias", "26.weight", "26.bias", "28.weight", "28.bias", "6.weight", "6.bias", "3.weight", "3.bias"

Note that in that issue, alphjheon simply comment out the code of loading weights to avoid the error.

Thanks.

@VE-yyq
Copy link

VE-yyq commented Dec 11, 2020

I got a similar error message while loading the baseline Model:
RuntimeError: Error(s) in loading state_dict for ResNetMulti: Missing key(s) in state_dict: "layer6.conv2d_list.0.weight", "layer6.conv2d_list.0.bias", "layer6.conv2d_list.1.weight", "layer6.conv2d_list.1.bias", "layer6.conv2d_list.2.weight", "layer6.conv2d_list.2.bias", "layer6.conv2d_list.3.weight", "layer6.conv2d_list.3.bias".size mismatch for layer5.conv2d_list.0.weight: copying a param with shape torch.Size([19, 2048, 3, 3]) from checkpoint, the shape in current model is torch.Size([19, 1024, 3, 3]).

@Lufei-github
Copy link

@JuiChang I get exactly the same result as you.
Now you can modify model.load_state_dict(new_params) to model.load_state_dict(new_params, strict=False).
Then it works.

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