StacyYang / gluoncv-torch

PyTorch API for GluonCV Models
MIT License
535 stars 62 forks source link

Error(s) in loading state_dict for ResNet when deep_base=True #19

Open Tensorfengsheng1926 opened 5 years ago

Tensorfengsheng1926 commented 5 years ago

Hi, thanks for the great work. I have encountered an error when loading the pretrained weight for resnet-101. RuntimeError: Error(s) in loading state_dict for ResNet: size mismatch for bn1.running_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for bn1.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for bn1.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for bn1.running_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for layer1.0.conv1.weight: copying a param with shape torch.Size([64, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([64, 128, 1, 1]). size mismatch for layer1.0.downsample.0.weight: copying a param with shape torch.Size([256, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 128, 1, 1]).

The parameter deep_base=True has been set. And there is no problem when deep_base=False .Could you help with this? Thanks!

sausagecy commented 5 years ago

I have the same problem, and when I change the parameters in function _make_layer, it causes layer2, layer3 and layer4 have mismatch problem