180705 Pytorch查看模型每层的输出形状

How to print output shape of each layer?
Keras style model.summary() in PyTorch

安装

pip install torchsummary

这里写图片描述

# -*- coding: utf-8 -*-
"""
Created on Thu Jul  5 14:22:03 2018

@author: guokai_liu
"""

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))A

猜你喜欢

转载自blog.csdn.net/qq_33039859/article/details/80934060