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"....
然后将
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]).
emmm....是预训练模型的锅吧
上一篇: pytorch 入门