import torch
模型路径
pthfile = r’C:\Users\q7529\Desktop\resnet50.pth’
由于模型原本是用GPU保存的,但我这台电脑上没有GPU,需要转化到CPU上
model = torch.load(pthfile, map_location=torch.device(‘cpu’))
print(“type:”)
类型是 dict
print(type(model))
print(“length:”)
查看模型字典长度
print(len(model))
print(“key:”)
查看模型字典里面的key
for k in model.keys():
print(k)
print(“value:”)
查看模型字典里面的value
for k in model:
print(k,model[k])