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

About loading pre-training errors #1

Closed
linyi785 opened this issue May 6, 2019 · 7 comments
Closed

About loading pre-training errors #1

linyi785 opened this issue May 6, 2019 · 7 comments

Comments

@linyi785
Copy link

linyi785 commented May 6, 2019

First of all, thank you for your code, which has benefited me a lot, but the same error always occurs when loading the pre-training model. The error code is as follows
Error(s) in loading state_dict for OctResNet:Missing key(s) in state_dict:
Can you help me with it, or can you provide me with a full version of the code? I am grateful! My email is bruceleely@outlook.com

@d-li14
Copy link
Owner

d-li14 commented May 6, 2019

@linyi785 Could you describe the detailed errors?
Everything went well on my side following these simple lines, without mismatched keys.

import torch
from oct_resnet import oct_resnet50
net = oct_resnet50()
net.load_state_dict(torch.load('/path/to/oct_resnet50_cosine.pth'))

@linyi785
Copy link
Author

linyi785 commented May 6, 2019

RuntimeError: Error(s) in loading state_dict for OctResNet:
Missing key(s) in state_dict: "layer1.0.conv1.bn_h.weight", "layer1.0.conv1.bn_h.bias", "layer1.0.conv1.bn_h.running_mean", "layer1.0.conv1.bn_h.running_var", "layer1.0.conv1.bn_l.weight", "layer1.0.conv1.bn_l.bias", "layer1.0.conv1.bn_l.running_mean", "layer1.0.conv1.bn_l.running_var", "layer1.0.conv2.bn_h.weight", "layer1.0.conv2.bn_h.bias", "layer1.0.conv2.bn_h.running_mean", "layer1.0.conv2.bn_h.running_var", "layer1.0.conv2.bn_l.weight", "layer1.0.conv2.bn_l.bias", "layer1.0.conv2.bn_l.running_mean", "layer1.0.conv2.bn_l.running_var", "layer1.0.conv3.conv.conv_l2l.weight", "layer1.0.conv3.conv.conv_l2h.weight", "layer1.0.conv3.conv.conv_h2l.weight", "layer1.0.conv3.conv.conv_h2h.weight", "layer1.0.conv3.bn_h.weight", "layer1.0.conv3.bn_h.bias", "layer1.0.conv3.bn_h.running_mean", "layer1.0.conv3.bn_h.running_var", "layer1.0.conv3.bn_l.weight", "layer1.0.conv3.bn_l.bias", "layer1.0.conv3.bn_l.running_mean", "layer1.0.conv3.bn_l.running_var", "layer1.0.downsample.0.conv.conv_h2l.weight", "layer1.0.downsample.0.conv.conv_h2h.weight", "layer1.0.downsample.0.bn_h.weight", "layer1.0.downsample.0.bn_h.bias", "layer1.0.downsample.0.bn_h.running_mean", "layer1.0.downsample.0.bn_h.running_var", "layer1.0.downsample.0.bn_l.weight", "layer1.0.downsample.0.bn_l.bias", "layer1.0.downsample.0.bn_l.running_mean", "layer1.0.downsample.0.bn_l.running_var", "layer1.1.conv1.bn_h.weight", "layer1.1.conv1.bn_h.bias", "layer1.1.conv1.bn_h.running_mean", "layer1.1.conv1.bn_h.running_var", "...
Unexpected key(s) in state_dict: "layer1.0.bn1.running_mean", "layer1.0.bn1.running_var", "layer1.0.bn1.weight", "layer1.0.bn1.bias", "layer1.0.bn2.running_mean", "layer1.0.bn2.running_var", "layer1.0.bn2.weight", "layer1.0.bn2.bias", "layer1.0.bn3.running_mean", "layer1.0.bn3.running_var", "layer1.0.bn3.weight", "layer1.0.bn3.bias", "layer1.0.conv1.weight", "layer1.0.conv2.weight", "layer1.0.conv3.weight", "layer1.0.downsample.1.running_mean", "layer1.0.downsample.1.running_var", "layer1.0.downsample.1.weight", "layer1.0.downsample.1.bias", "layer1.0.downsample.0.weight", "layer1.1.bn1.running_mean", "layer1.1.bn1.running_var", "layer1.1.bn1.weight", "layer1.1.bn1.bias", "layer1.1.bn2.running_mean", "layer1.1.bn2.running_var", "layer1.1.bn2.weight", "layer1.1.bn2.bias", "layer1.1.bn3.running_mean", "layer1.1.bn3.running_var", "layer1.1.bn3.weight", "layer1.1.bn3.bias", "layer1.1.conv1.weight", "layer1.1.conv2.weight", "layer1.1.conv3.weight", "layer1.2.bn1.running_mean", "layer1.2.bn1.running_var", "layer1.2.bn1.weight", "layer1.2.bn1.bias", "layer1.2.bn2.running_mean", "layer1.2.bn2.running_var", "layer1.2.bn2.weight", "layer1.2.bn2.bias", "layer1.2.bn3.running_mean", "layer1.2.bn3.running_var", "layer1.2.bn3.weight", "layer1.2.bn3.bias", "layer1.2.conv1.weight", "layer1.2.conv2.weight", "layer1.2.conv3.weight", "layer2.0.bn1.running_mean", "layer2.0.bn1.running_var", "layer2.0.bn1.weight", "layer2.0.bn1.bias", "layer2.0.bn2.running_mean", "layer2.0.bn2.running_var", "l...

@linyi785
Copy link
Author

linyi785 commented May 6, 2019

The pre-training weight I used is that the standard resnet50 is not oct_resnet50. Is it wrong here?

@d-li14
Copy link
Owner

d-li14 commented May 6, 2019

The architecture of vanilla ResNet and OctResNet is different in almost all layers, so directly loading the weight of ResNet to OctResNet causes the error you met.

@linyi785
Copy link
Author

linyi785 commented May 6, 2019

thanks!By the way,Is your pre-training weight trained on the ImageNet dataset?

@d-li14
Copy link
Owner

d-li14 commented May 6, 2019

yes

@linyi785
Copy link
Author

linyi785 commented May 6, 2019

Thank you very much for solving all my doubts.

@d-li14 d-li14 closed this as completed May 6, 2019
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