对于想知道网络模型具体结构的,这个 Netron
可视化工具值得推荐 !
话不多说,先看效果:
使用 model.summary()
函数打印出来的网络结构:
==========================================================================================
Layer (type:depth-idx) Output Shape Param #
==========================================================================================
simpleNet -- --
├─Sequential: 1-1 [64, 16, 16, 16] --
│ └─Conv2d: 2-1 [64, 16, 32, 32] 448
│ └─BatchNorm2d: 2-2 [64, 16, 32, 32] 32
│ └─MaxPool2d: 2-3 [64, 16, 16, 16] --
│ └─ReLU: 2-4 [64, 16, 16, 16] --
├─Sequential: 1-2 [64, 32, 8, 8] --
│ └─Conv2d: 2-5 [64, 32, 16, 16] 4,640
│ └─BatchNorm2d: 2-6 [64, 32, 16, 16] 64
│ └─MaxPool2d: 2-7 [64, 32, 8, 8] --
│ └─ReLU: 2-8 [64, 32, 8, 8] --
├─Sequential: 1-3 [64, 64, 4, 4] --
│ └─Conv2d: 2-9 [64, 64, 8, 8] 18,496
│ └─BatchNorm2d: 2-10 [64, 64, 8, 8] 128
│ └─MaxPool2d: 2-11 [64, 64, 4, 4] --
│ └─ReLU: 2-12 [64, 64, 4, 4] --
├─Dropout: 1-4 [64, 1024] --
├─Linear: 1-5 [64, 10] 10,250
├─Linear: 1-6 [64, 10] 110
==========================================================================================
Total params: 34,168
Trainable params: 34,168
Non-trainable params: 0
Total mult-adds (M): 181.82
==========================================================================================
Input size (MB): 0.79
Forward/backward pass size (MB): 29.37
Params size (MB): 0.14
Estimated Total Size (MB): 30.29
==========================================================================================
使用 Netron
网络结构可视化:
Github链接:Netron
macOS : Download the .dmg file or run brew install netron
Linux : Download the .AppImage file or run snap install netron
Windows : Download the .exe installer or run winget install -s winget netron
Browser : Start the browser version
Python Server : Run pip install netron
and netron [FILE]
or netron.start('[FILE]')
Browser在线版本:Ntron
使用时只需要将模型 Model 文件导入即可