pytorch network visualization (1): torchsummary

1. Install torchsummary

Enter your own pytorch environment in the Anaconda prompt and install dependent packages.

pip install torchsummary

The details are as follows (pytorch-cpu is my own pytorch environment):

torchsummary installation

2. Test whether the download is successful

After the installation is complete, run python to enter the interactive environment and import torchsummary. If no error is reported, the installation is successful.

Import torchsummary

3. Output network structure

After completing the above steps, enter your own python editing environment and run the following code.

from torchsummary import summary
from torchvision.models import vgg16  # 以 vgg16 为例

myNet = vgg16()  # 实例化网络,可以换成自己的网络
summary(myNet, (3, 64, 64))  # 输出网络结构

Running the code, the results are as follows (VGG16):

Insert image description here
Insert image description here
It can be seen that torchsummary can not only view the sequential structure of the network, but also the network parameters, network model size and other information, which is very practical.

Guess you like

Origin blog.csdn.net/Wenyuanbo/article/details/118514709