Problem in loading ResNeXt-101
See original GitHub issueHi Kensho,
Thanks a lot for this repo. I am trying to extract features using ResNeXt-101 model (to be exact, I am using this file: resnext-101-kinetics-ucf101_split1.pth). The file seems to be loading (w = torch.load(opt.model)
) correctly, which I confirmed by printing the weights. But when I try to load state dictionary using the code below, I get the following errors: Unexpected key(s) in state_dict: “layer1.0.downsample.0.weight”, “layer1.0.downsample.1.weight”, …
Snippet for loading state dictionary:
state_dict = w['state_dict']
new_state_dict = OrderedDict()
for k, v in state_dict.items():
name = k[7:] # remove `module.`
new_state_dict[name] = v
model.load_state_dict(new_state_dict)
I used the snippet above because I was getting the following error: Unexpected key(s) in state_dict: “module.conv1.weight”, “module.bn1.weight”, “module.bn1.bias”, …
Also, I was able to load state dictionary correctly using above snippet for ResNet-34. So, I believe there might be conflict in PyTorch versions (I am using 0.4.0). I wanted to use ResNeXt because it’s best performing model. Could you please let us know how to resolve this issue?
Thank you
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top GitHub Comments
I found the solution: change the shortcut type to B for ResNeXt-101.
@ParitoshParmar Thank you, your solution is worked for me.