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.

size mismatch for aspp when loading pre-trained model

See original GitHub issue

Hi!

Very nice repo! I’m currently trying to integrate your model into our framework (https://github.com/DIVA-DIA/DeepDIVA, feel free to check it out!). However, when I load the provided weights for deeplabv3 I get the following error:

	size mismatch for aspp.conv_1x1_4.weight: copying a param with shape torch.Size([20, 256, 1, 1]) from checkpoint, the shape in current model is torch.Size([8, 256, 1, 1]).
	size mismatch for aspp.conv_1x1_4.bias: copying a param with shape torch.Size([20]) from checkpoint, the shape in current model is torch.Size([8]). (deeplabv3.py:50)

I am using exactly the Resnet (ResNet18_OS8) and the ASPP (no bottleneck) that you are using in your code. Do you know what could be causing this?

Thank you very much already in advance.

Cheers, Linda

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fregu856commented, Feb 20, 2019

The pre-trained resnets are taken straight from torchvision, i.e., downloaded from the urls at the top of https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py.

0reactions
LindaStcommented, Feb 20, 2019

Thank you so much for your quick response! Yes, my model has a different number of classes.

Somewhat unrelated question: the pre-trained weights provided for the resnets are for the cityscape model aswell, or from something else?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pytorch-size mismatch when loading the pretrained model
I want to load my pretrained models for reinforcement learning. That's how I save and load the model: def save(self, folder_to_save='.
Read more >
Size mismatch when loading pretrained model #1340 - GitHub
I'm seeing this: In [1]: import pytorch_transformers In [2]: m=pytorch_transformers.AutoModel.from_pretrained('roberta-base') ...
Read more >
Transfer learning with different model shapes (error: size ...
Loading my 2-category model weights into the ConvLearner that has been primed with scalar-shaped data leads to two errors: size mismatch for ......
Read more >
Size mismatch for decoder.rule_logits.weight , bias and ...
I am wondering if there is any fix I can do to solve this and perform inference with the pre-trained model. Thanks a...
Read more >
you may consider adding `ignore_mismatched_sizes=true` in the ...
I'm trying to load a pretrained pytorch Bert model with a different ... Kindly specify the way to load model with size mismatch,...
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