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

size mismatch for pretrained models #223

Open
itongworld opened this issue Nov 24, 2020 · 2 comments
Open

size mismatch for pretrained models #223

itongworld opened this issue Nov 24, 2020 · 2 comments

Comments

@itongworld
Copy link

In image_captioning tutorial, I followed every step in the README.md file but error occurs when loading the pretrained model:

root@localhost:~/captioning/pytorch-tutorial/tutorials/03-advanced/image_captioning# python3 sample.py --image='png/example.png'
Downloading: "https://download.pytorch.org/models/resnet152-b121ed2d.pth" to /root/.cache/torch/checkpoints/resnet152-b121ed2d.pth
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 230M/230M [00:22<00:00, 10.5MB/s]
Traceback (most recent call last):
  File "sample.py", line 81, in <module>
    main(args)
  File "sample.py", line 44, in main
    decoder.load_state_dict(torch.load(args.decoder_path))
  File "/anaconda3/envs/fewshot/lib/python3.8/site-packages/torch/nn/modules/module.py", line 829, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for DecoderRNN:
	size mismatch for embed.weight: copying a param with shape torch.Size([9956, 256]) from checkpoint, the shape in current model is torch.Size([9948, 256]).
	size mismatch for linear.weight: copying a param with shape torch.Size([9956, 512]) from checkpoint, the shape in current model is torch.Size([9948, 512]).
	size mismatch for linear.bias: copying a param with shape torch.Size([9956]) from checkpoint, the shape in current model is torch.Size([9948]).

Is there any problems in the pretrained models?

@Matten95
Copy link

I encounter the same question, anyone solved?

@aileenz20
Copy link

Have you solved this problem? @itongworld

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

No branches or pull requests

3 participants