欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Pytorch入门

程序员文章站 2022-07-06 13:01:22
...

PoolNet2019

1.预训练模型修改为VGG报错:RuntimeError: Error(s) in loading state_dict for PoolNet:
        Missing key(s) in state_dict: "base.vgg16.base.0.weight", "base.vgg16.base.0.bias", "base.vgg16.base.2.weight", "base.vgg16.base.2.bias", "base.vgg16.base.5.weight"....

Pytorch入门

查找到网页https://discuss.pytorch.org/t/solved-keyerror-unexpected-key-module-encoder-embedding-weight-in-state-dict/1686/15

然后将

self.net.load_state_dict(torch.load(self.config.model, map_location='cpu'))

添加字段,改成

self.net.load_state_dict(torch.load(self.config.model, map_location='cpu'),strict=False)

参数不匹配倒是解决了,但出现了新问题

RuntimeError: Error(s) in loading state_dict for PoolNet:
        size mismatch for base.infos.2.0.weight: copying a param with shape torch.Size([256, 512, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 512, 3, 3]).

Pytorch入门

emmm....是预训练模型的锅吧

相关标签: Deep learning