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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM