RuntimeError: Error(s) in loading state_dict for

1.在载入模型参数前加上:

model = nn.DataParallel(model)

2.更改torch版本
部分原因是模型之间torch版本不匹配导致,加载使用模型时和训练模型时的环境不一致,可以重新安装torch
3.增加load_state_dict()属性

model.load_state_dict(checkpoint['state_dict'], strict=False)


版权声明:本文为weixin_36670529原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。