目录
torchsummary打印
pip install torchsummary
import torch
from torchvision import models
from torchsummary import summary
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
vgg = models.vgg16().to(device)
summary(vgg, (3, 224, 224))
打印模型参数,两种方法结果好像是一样的
state_dict2=model.state_dict()
for name, param in state_dict2.items():
print(name,param.size(),'state_dict')
for name, param in model.named_parameters():
print(name,param.size(),'parameter&