torch.load()加载模型,提示xxx.pt is a zip archive(did you mean to use torch.jit.load()?)

参考链接

https://blog.csdn.net/irober/article/details/115144522?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-0&spm=1001.2101.3001.4242

torch版本问题

import torch
state_dict = torch.load("./model_00050.pt")#加载原来的模型  在torch=1.6时加载
torch.save(state_dict, "./00050.pt", _use_new_zipfile_serialization=False)#不是zip 

再加载save后的模型即可

posted on 2021-04-02 10:00  cltt  阅读(2584)  评论(0编辑  收藏  举报

导航