pytorch加载模型时出现…xxx.pth is a zip archive (did you mean to use torch.jit.load()?)
这是因为新版本pytorch默认把模型存储为压缩文件,老版本不是压缩文件
解决方法:在新版本中将模型加载后,再存储为非压缩文件,再用老版本加载:
import torch
state_dict = torch.load("xxx.pth") #xxx.pth或者xxx.pt就是你想改掉的权重文件
torch.save(state_dict, "xxx.pth", _use_new_zipfile_serialization=False)