question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem in loading ResNeXt-101

See original GitHub issue

Hi 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:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
ParitoshParmarcommented, Jul 19, 2018

I found the solution: change the shortcut type to B for ResNeXt-101.

0reactions
tuyunbincommented, Jun 20, 2019

@ParitoshParmar Thank you, your solution is worked for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Facing problem loading pretained architecture resnext101_64 ...
I'm facing problem loading pretrained architecture resnext101_64 while working in kaggle kernels . The code searches for weights at ...
Read more >
ResNeXt | Papers With Code
How do I load this model? To load a pretrained model: python import torchvision.models as models resnext50_32x4d ... ResNeXt-101-32x8d ...
Read more >
ResNeXt101 - PyTorch
The ResNeXt101-32x4d is a model introduced in the Aggregated Residual Transformations ... resneXt = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', ...
Read more >
Unable to load custom pretrained weight in Pytorch Lightning
The reason why you're getting this error is because you are trying to load your PyTorch's model weights into the Lightning module.
Read more >
examples/resnet50v1.5/resnext101-32x4d/training/AMP ... - GitLab
An error occurred while loading commit signatures ... dsri-pytorch-workspace · examples · resnet50v1.5 · resnext101-32x4d · training ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found