pytorch打印自定义网络的每层的名称

pytorch打印自定义网络的每层的名称

import torch
from torchvision import models
from torchsummary import summary
from resnext_MulTask_clothes import resnext50_elastic


data_class=[8, 7]
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# vgg = models.vgg16().to(device)

model = resnext50_elastic(num_classes=data_class) # 原模型
model = torch.nn.DataParallel(model).cuda() # 并行处理
# 已训练好的模型的pth文件
checkpoint = torch.load('06-resnext50_elastic_checkpoint.pth.tar')
model.load_state_dict(checkpoint['state_dict'], strict=False) # 参数加载

summary(model, (3, 224, 224))

参考连接:https://www.jianshu.com/p/97c626d33924

另:
打印resnet152网络的每层的名称

import torch
from torchvision import models
from torchsummary import summary
from resnet_pretrained import resnet152

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

model = resnet152() # 原模型
model = torch.nn.DataParallel(model).cuda() # 并行处理
# 已训练好的模型的pth文件
checkpoint = torch.load('resnet152-b121ed2d.pth')

model.load_state_dict(checkpoint, strict=False) # 参数加载

summary(model, (3, 224, 224))
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值