torch-summary的无效输出
==========================================================================================
Layer (type:depth-idx) Output Shape Param #
==========================================================================================
└─Generator: 0-1 [-1, 3, 256, 256] --
==========================================================================================
Total params: 0
Trainable params: 0
Non-trainable params: 0
Total mult-adds (M): 0.00
==========================================================================================
Input size (MB): 0.00
Forward/backward pass size (MB): 0.00
Params size (MB): 0.00
Estimated Total Size (MB): 0.00
=========================================================================================
tensorboard 报错
Cannot insert a Tensor that requires grad as a constant. Consider making it a parameter or input, or detaching the gradient
参考 博客
构建模型时,不应使用的是python原生 list
,而应使用 nn.ModuleList
构建完后使用 self.layers = nn.ModuleList(self.layers)
将原生 list
转换为 nn.ModuleList
即可。
====================================================================================================
Layer (type:depth-idx) Output Shape Param #
====================================================================================================
├─ModuleList: 1 [] --
| └─Sequential: 2-1 [-1, 512, 4, 4] --
| | └─ParametrizedConvTranspose2d: 3-1 [-1, 512, 4, 4] 819,712
| | └─BatchNorm2d: 3-2 [-1, 512, 4, 4] 1,024
| | └─ReLU: 3-3 [-1, 512, 4, 4] --
| └─Sequential: 2-2 [-1, 256, 8, 8] --
| | └─ParametrizedConvTranspose2d: 3-4 [-1, 256, 8, 8] 2,097,408
| | └─BatchNorm2d: 3-5 [-1, 256, 8, 8] 512
| | └─ReLU: 3-6 [-1, 256, 8, 8] --
| └─Sequential: 2-3 [-1, 128, 16, 16] --
| | └─ParametrizedConvTranspose2d: 3-7 [-1, 128, 16, 16] 524,416
| | └─BatchNorm2d: 3-8 [-1, 128, 16, 16] 256
| | └─ReLU: 3-9 [-1, 128, 16, 16] --
| └─Sequential: 2-4 [-1, 64, 32, 32] --
| | └─ParametrizedConvTranspose2d: 3-10 [-1, 64, 32, 32] 131,136
| | └─BatchNorm2d: 3-11 [-1, 64, 32, 32] 128
| | └─ReLU: 3-12 [-1, 64, 32, 32] --
| └─Sequential: 2-5 [-1, 32, 64, 64] --
| | └─ParametrizedConvTranspose2d: 3-13 [-1, 32, 64, 64] 32,800
| | └─BatchNorm2d: 3-14 [-1, 32, 64, 64] 64
| | └─ReLU: 3-15 [-1, 32, 64, 64] --
| | └─Self_Attn: 3-16 [-1, 32, 64, 64] 1,321
| └─Sequential: 2-6 [-1, 16, 128, 128] --
| | └─ParametrizedConvTranspose2d: 3-17 [-1, 16, 128, 128] 8,208
| | └─BatchNorm2d: 3-18 [-1, 16, 128, 128] 32
| | └─ReLU: 3-19 [-1, 16, 128, 128] --
| | └─Self_Attn: 3-20 [-1, 16, 128, 128] 341
| └─Sequential: 2-7 [-1, 3, 256, 256] --
| | └─ParametrizedConvTranspose2d: 3-21 [-1, 3, 256, 256] 771
| | └─Tanh: 3-22 [-1, 3, 256, 256] --
====================================================================================================
Total params: 3,618,129
Trainable params: 3,618,129
Non-trainable params: 0
Total mult-adds (M): 17.72
====================================================================================================
Input size (MB): 0.00
Forward/backward pass size (MB): 7.69
Params size (MB): 13.80
Estimated Total Size (MB): 21.49
====================================================================================================
tensorboard也不再报错