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 when loading the trained checkpoint

See original GitHub issue

For the adaptation from VOC to watercolor, VOC has 21 classes (background included) and the watercolor dataset has 7 classes, how do you deal with the inconsistency? It seems that the classifier obtained in the training stage cannot be applied for the test stage. Thanks.

*** RuntimeError: Error(s) in loading state_dict for resnet:
	size mismatch for RCNN_cls_score.weight: copying a param of torch.Size([7, 2304]) from checkpoint, where the shape is torch.Size([21, 2304]) in current model.
	size mismatch for RCNN_cls_score.bias: copying a param of torch.Size([7]) from checkpoint, where the shape is torch.Size([21]) in current model.
	size mismatch for RCNN_bbox_pred.weight: copying a param of torch.Size([28, 2304]) from checkpoint, where the shape is torch.Size([84, 2304]) in current model.
	size mismatch for RCNN_bbox_pred.bias: copying a param of torch.Size([28]) from checkpoint, where the shape is torch.Size([84]) in current model.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

2reactions
123zhen123commented, Oct 13, 2019

I have the same questions

0reactions
123zhen123commented, Oct 13, 2019

对于从VOC到水彩的适应,VOC有21个类(包括背景),水彩数据集有7个类,您如何处理不一致的情况?看来在训练阶段获得的分类器无法应用于测试阶段。谢谢。

*** RuntimeError: Error(s) in loading state_dict for resnet:
	size mismatch for RCNN_cls_score.weight: copying a param of torch.Size([7, 2304]) from checkpoint, where the shape is torch.Size([21, 2304]) in current model.
	size mismatch for RCNN_cls_score.bias: copying a param of torch.Size([7]) from checkpoint, where the shape is torch.Size([21]) in current model.
	size mismatch for RCNN_bbox_pred.weight: copying a param of torch.Size([28, 2304]) from checkpoint, where the shape is torch.Size([84, 2304]) in current model.
	size mismatch for RCNN_bbox_pred.bias: copying a param of torch.Size([28]) from checkpoint, where the shape is torch.Size([84]) in current model.

Have you solved the problem?

Read more comments on GitHub >

github_iconTop Results From Across the Web

size mismatch when loading checkpoint (ssf2020) #113 - GitHub
I am trying to load a checkpoint after training the ssf2020 model. However, when I load the checkpoint, a size mismatch error occurs....
Read more >
Size Mismatch Runtime Error When Trying to Load a PyTorch ...
It seems to me that your model configuration does not match the content of the model checkpoint. I imagine your model has parameters...
Read more >
Training my pretrained model in different dataset and I got an ...
Size ([6, 128]) from checkpoint, the shape in current model is torch.Size([7, 128]). size mismatch for crop_encoder.bn2.embed.weight: copying a ...
Read more >
Intro-to-PyTorch: Saving and Loading Models | Kaggle
Size ([512]) from checkpoint, the shape in current model is torch.Size([400]). size mismatch for hidden_layers.1.weight: copying a param with shape torch.Size([ ...
Read more >
T5ForConditionalGeneration checkpoint size mismatch #19418
Loading the model. This is how I'm loading the model: tokenizer = T5Tokenizer.from_pretrained(args["model_checkpoint"], bos_token=" ...
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