Skip to content

size mismatch for pretrained models #223

Open
@itongworld

Description

@itongworld

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions