chenyuntc / pytorch-book

PyTorch tutorials and fun projects including neural talk, neural style, poem writing, anime generation (《深度学习框架PyTorch:入门与实战》)
MIT License
11.99k stars 3.73k forks source link

chapter 10 size mismatch when running demo.ipynb #209

Open EdgyRoger opened 4 years ago

EdgyRoger commented 4 years ago

作者大大你好,我这边在运行demo.ipynb文件时前面都能正常运行,但最后一个代码块报错: image 好像是预训练模型的参数不匹配?但是网上查了很久也没有找到解决办法,能否帮我看看这个问题呢?感激不尽!

EdgyRoger commented 4 years ago

RuntimeError: Error(s) in loading state_dict for CaptionModel: size mismatch for classifier.weight: copying a param with shape torch.Size([10003, 256]) from checkpoint, the shape in current model is torch.Size([5003, 256]). size mismatch for classifier.bias: copying a param with shape torch.Size([10003]) from checkpoint, the shape in current model is torch.Size([5003]). size mismatch for embedding.weight: copying a param with shape torch.Size([10003, 256]) from checkpoint, the shape in current model is torch.Size([5003, 256]). 上面的图片好像显示不了,这里列一下文字。

HN123-123 commented 4 years ago

请问您这个问题解决了吗。我在测试demo时候也遇到了同样的问题。

wenshijie110 commented 3 years ago

这种情况是因为你自己生成caption.pth的时候修改了一些参数,你下载作者给的caption.pth就不会出现这种问题了