use torchsummary package to get summary of the model to see the output shape and the number of parameters in each layer.
1. install the torchsummary package:
pip install torchsummary
2. let's get the model summary using torchsummary:
from torchsummary import summary
summary(model, input_size=(channels, H, W))
----------------------------------------------------------------
Layer (type) Output Shape Param #
================================================================
Conv2d-1 [-1, 10, 24, 24] 260
Conv2d-2 [-1, 20, 8, 8] 5,020
Dropout2d-3 [-1, 20, 8, 8] 0
Linear-4 [-1, 50] 16,050
Linear-5 [-1, 10] 510
================================================================
Total params: 21,840
Trainable params: 21,840
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.00
Forward/backward pass size (MB): 0.06
Params size (MB): 0.08
Estimated Total Size (MB): 0.15
----------------------------------------------------------------
※ reference: github.com/sksq96/pytorch-summary
'머신러닝 > Pytorch' 카테고리의 다른 글
define the optimizer and the learning rate schedule (0) | 2021.01.06 |
---|---|
visualize the filters of the first CNN layer (0) | 2021.01.06 |
store best weights (0) | 2021.01.04 |
Storing and loading models (0) | 2020.12.31 |
pytorch 1.7.1 + cuda 11.0 + cudnn 8.0.5.39 on windows (0) | 2020.12.14 |