当前位置:网站首页>pytorch 1.7. The model saved by X training cannot be loaded in version 1.4 or earlier

pytorch 1.7. The model saved by X training cannot be loaded in version 1.4 or earlier

2022-04-23 20:47:00 NuerNuer

pytorch1.6.x And higher , There is a difference between saving a model and a lower version , Therefore, the high version of the saved model fails to load in the low version :

We just need to be in a higher version torch When saving under , Set up _use_new_zipfile_serialization=False

weights = 'xxx.pth'
temp = torch.load(weights)
...  
data = ... #type:OrderedDict
torch.save(data, 'new_model.pth', _use_new_zipfile_serialization=False)

About data The processing methods of models saved in different ways are not quite the same , Find out how your model is saved , For several common preservation forms, please refer to my blog :
https://blog.csdn.net/qq_41368074/article/details/120812819
A specific example can be referred to :
https://blog.csdn.net/flying_ant2018/article/details/115403774

版权声明
本文为[NuerNuer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210545523016.html