1.在载入模型参数前加上:
model = nn.DataParallel(model)
2.更改torch版本
部分原因是模型之间torch版本不匹配导致,加载使用模型时和训练模型时的环境不一致,可以重新安装torch
3.增加load_state_dict()属性
model.load_state_dict(checkpoint['state_dict'], strict=False)
1.在载入模型参数前加上:
model = nn.DataParallel(model)
2.更改torch版本
部分原因是模型之间torch版本不匹配导致,加载使用模型时和训练模型时的环境不一致,可以重新安装torch
3.增加load_state_dict()属性
model.load_state_dict(checkpoint['state_dict'], strict=False)