RuntimeError: Error(s) in loading state_dict for

丹柯yx

关注

阅读 77

2022-04-24

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

model = nn.DataParallel(model)

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

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

精彩评论(0)

0 0 举报