我有一个带有权重的.pth文件。我如何才能从这个文件中查看权重?
我试着加载和查看这段代码,但是它不起作用(作为新手,我可能完全错了)-
import torch
import torchvision.models as models
torch.save('weights\kharif_crops_final.pth')
models.load_state_dict(torch.load('weights\kharif_crops_final.pth'))
models.eval()
print(models)发布于 2022-04-05 17:34:48
import torch
model = torch.load('path')
print(model)(核实和确认)
发布于 2022-04-06 03:18:46
PATH = 'weights\kharif_crops_final.pth'
state = {'model': model.state_dict()}
torch.save(state, PATH)
model.load_state_dict(torch.load(PATH)['model'])
# print weights
for k, v in model.named_parameters():
print(k, v)https://stackoverflow.com/questions/71754506
复制相似问题