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

Need to put norm_layer as a parameter. #2080

Closed
phamquiluan opened this issue Apr 9, 2020 · 1 comment · Fixed by #2081
Closed

Need to put norm_layer as a parameter. #2080

phamquiluan opened this issue Apr 9, 2020 · 1 comment · Fixed by #2081

Comments

@phamquiluan
Copy link
Contributor

norm_layer=misc_nn_ops.FrozenBatchNorm2d)

It works fine with resnet50_fpn, but when I try to use another backbone, for example resnext101_32x8d

norm_layer=misc_nn_ops.FrozenBatchNorm2d may trouble with Imagenet pretrained weights, which use BatchNorm

Traceback (most recent call last):
  File "tmp.py", line 4, in <module>
    m = maskrcnn_resnext101_32x8d_rpn(pretrained=True)
  File "/mnt/data/luan/maskrcnn/models.py", line 218, in maskrcnn_resnext101_32x8d_rpn                                                                                      
    "resnext101_32x8d", pretrained=pretrained)
  File "/mnt/data/luan/anaconda3/envs/mask/lib/python3.6/site-packages/torchvision/models/detection/backbone_utils.py", line 47, in resnet_fpn_backbone                     
    norm_layer=misc_nn_ops.FrozenBatchNorm2d)
  File "/mnt/data/luan/anaconda3/envs/mask/lib/python3.6/site-packages/torchvision/models/resnet.py", line 313, in resnext101_32x8d                                         
    pretrained, progress, **kwargs)
  File "/mnt/data/luan/anaconda3/envs/mask/lib/python3.6/site-packages/torchvision/models/resnet.py", line 224, in _resnet                                                  
    model.load_state_dict(state_dict)
  File "/mnt/data/luan/anaconda3/envs/mask/lib/python3.6/site-packages/torch/nn/modules/module.py", line 830, in load_state_dict                                            
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for ResNet:
        Unexpected key(s) in state_dict: "bn1.num_batches_tracked", "layer1.0.bn1.num_batches_tracked", "layer1.0.bn2.num_batches_tracked", "layer1.0.bn3.num_batches_tracked", "layer1.0.downsample.1.num_batches_tracked", "layer1.1.bn1.num_batches_tracked", "layer1.1.bn2.num_batches_tracked", "layer1.1.bn3.num_batches_tracked", "layer1.2.bn1.num_batches_tracked", "layer1.2.bn2.num_batches_tracked", "layer1.2.bn3.num_batches_tracked", "layer2.0.bn1.num_batches_tracked", "layer2.0.bn2.num_batches_tracked", "layer2.0.bn3.num_batches_tracked", "layer2.0.downsample.1.num_batches_tracked", "layer2.1.bn1.num_batches_tracked", "layer2.1.bn2.num_batches_tracked", "layer2.1.bn3.num_batches_tracked", "layer2.2.bn1.num_batches_tracked", "layer2.2.bn2.num_batches_tracked", "layer2.2.bn3.num_batches_tracked", "layer2.3.bn1.num_batches_tracked", "layer2.3.bn2.num_batches_tracked", "layer2.3.bn3.num_batches_tracked", "layer3.0.bn1.num_batches_tracked", "layer3.0.bn2.num_batches_tracked", "layer3.0.bn3.num_batches_tracked", "layer3.0.downsample.1.num_batches_tracked", "layer3.1.bn1.num_batches_tracked", "layer3.1.bn2.num_batches_tracked", "layer3.1.bn3.num_batches_tracked", "layer3.2.bn1.num_batches_tracked",
"layer3.2.bn2.num_batches_tracked", "layer3.2.bn3.num_batches_tracked", "layer3.3.bn1.num_batches_tracked", "layer3.3.bn2.num_batches_tracked", "layer3.3.bn3.num_batches_tracked", "layer3.4.bn1.num_batches_tracked", "layer3.4.bn2.num_batches_tracked", "layer3.4.bn3.num_batches_tracked", "layer3.5.bn1.num_batches_tracked", "layer3.5.bn2.num_batches_tracked", "layer3.5.bn3.num_batches_tracked", "layer3.6.bn1.num_batches_tracked", "layer3.6.bn2.num_batches_tracked", "layer3.6.bn3.num_batches_tracked", "layer3.7.bn1.num_batches_tracked", "layer3.7.bn2.num_batches_tracked", "layer3.7.bn3.num_batches_tracked", "layer3.8.bn1.num_batches_tracked", "layer3.8.bn2.num_batches_tracked", "layer3.8.bn3.num_batches_tracked", "layer3.9.bn1.num_batches_tracked", "layer3.9.bn2.num_batches_tracked", "layer3.9.bn3.num_batches_tracked", "layer3.10.bn1.num_batches_tracked",
"layer3.10.bn2.num_batches_tracked", "layer3.10.bn3.num_batches_tracked", "layer3.11.bn1.num_batches_tracked", "layer3.11.bn2.num_batches_tracked", "layer3.11.bn3.num_batches_tracked", "layer3.12.bn1.num_batches_tracked", "layer3.12.bn2.num_batches_tracked", "layer3.12.bn3.num_batches_tracked", "layer3.13.bn1.num_batches_tracked", "layer3.13.bn2.num_batches_tracked", "layer3.13.bn3.num_batches_tracked", "layer3.14.bn1.num_batches_tracked", "layer3.14.bn2.num_batches_tracked", "layer3.14.bn3.num_batches_tracked", "layer3.15.bn1.num_batches_tracked", "layer3.15.bn2.num_batches_tracked", "layer3.15.bn3.num_batches_tracked", "layer3.16.bn1.num_batches_tracked", "layer3.16.bn2.num_batches_tracked", "layer3.16.bn3.num_batches_tracked", "layer3.17.bn1.num_batches_tracked", "layer3.17.bn2.num_batches_tracked", "layer3.17.bn3.num_batches_tracked", "layer3.18.bn1.num_batches_tracked", "layer3.18.bn2.num_batches_tracked", "layer3.18.bn3.num_batches_tracked", "layer3.19.bn1.num_batches_tracked", "layer3.19.bn2.num_batches_tracked", "layer3.19.bn3.num_batches_tracked", "layer3.20.bn1.num_batches_tracked", "layer3.20.bn2.num_batches_tracked", "layer3.20.bn3.num_batches_tracked", "layer3.21.bn1.num_batches_tracked", "layer3.21.bn2.num_batches_tracked", "layer3.21.bn3.num_batches_tracked", "layer3.22.bn1.num_batches_tracked", "layer3.22.bn2.num_batches_tracked", "layer3.22.bn3.num_batches_tracked", "layer4.0.bn1.num_batches_tracked", "layer4.0.bn2.num_batches_tracked", "layer4.0.bn3.num_batches_tracked", "layer4.0.downsample.1.num_batches_tracked", "layer4.1.bn1.num_batches_tracked", "layer4.1.bn2.num_batches_tracked", "layer4.1.bn3.num_batches_tracked", "layer4.2.bn1.num_batches_tracked", "layer4.2.bn2.num_batches_tracked", "layer4.2.bn3.num_batches_tracked".

@fmassa
Copy link
Member

fmassa commented Apr 9, 2020

Actually, the error you are facing has been fixed with #1728

But the PR that you linked is ok with me, I would have exposed **kwargs instead, but that's fine

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

Successfully merging a pull request may close this issue.

2 participants