PyTorch错误解决:XXX is a zip archive(did you mean to use torch.jit.load()?)

错误原因:

训练保存模型时,torch的版本是1.6.0(使用torch.__version__可以查看torch的版本号

而加载模型时,torch的版本号低于1.6.0

 

解决方案:

If for any reason you want torch.save to use the old format, pass the kwarg _use_new_zipfile_serialization=False.

在训练时更改参数“_use_new_zipfile_serialization=False”,

torch.save(model.state_dict(), model_cp,_use_new_zipfile_serialization=False)  # 训练所有数据后,保存网络的参数

 

参考:https://blog.csdn.net/weixin_44769214/article/details/108188126

 

posted @ 2020-10-20 09:43  不学无墅_NKer  阅读(12121)  评论(0编辑  收藏  举报