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

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

安装

pip install torchsummary

180705 Pytorch查看模型每层的输出形状_第1张图片

# -*- 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

你可能感兴趣的:(Pytorch)