paddle 如何逐层打印特征图的尺寸?
收藏
2.0后用Sequential太方便了,但不能逐层打印特征图了。
0
收藏
请登录后评论
2.0还没有使用555
动态图无所畏惧
试试paddle.summary
或者
model = paddle.Model(...)
model.summary(...)
谢谢大侠!
这就去试试~
BEAUTIFUL!
--------------------------------------------------------------------------------
Layer (type) Input Shape Output Shape Param #
================================================================================
Conv2d-11 [1, 1, 28, 28] [1, 64, 14, 14] 3,200
BatchNorm2d-10 [1, 64, 14, 14] [1, 64, 14, 14] 256
ReLU-6 [1, 64, 14, 14] [1, 64, 14, 14] 0
Pool2D-3 [1, 64, 14, 14] [1, 64, 7, 7] 0
Conv2d-12 [1, 64, 7, 7] [1, 64, 7, 7] 36,928
BatchNorm2d-11 [1, 64, 7, 7] [1, 64, 7, 7] 256
ReLU-7 [1, 64, 7, 7] [1, 64, 7, 7] 0
Conv2d-13 [1, 64, 7, 7] [1, 64, 7, 7] 36,928
BatchNorm2d-12 [1, 64, 7, 7] [1, 64, 7, 7] 256
Residual-5 [1, 64, 7, 7] [1, 64, 7, 7] 0
Conv2d-14 [1, 64, 7, 7] [1, 64, 7, 7] 36,928
BatchNorm2d-13 [1, 64, 7, 7] [1, 64, 7, 7] 256
ReLU-8 [1, 64, 7, 7] [1, 64, 7, 7] 0
Conv2d-15 [1, 64, 7, 7] [1, 64, 7, 7] 36,928
BatchNorm2d-14 [1, 64, 7, 7] [1, 64, 7, 7] 256
Residual-6 [1, 64, 7, 7] [1, 64, 7, 7] 0
ResnetBlock-3 [1, 64, 7, 7] [1, 64, 7, 7] 0
Conv2d-16 [1, 64, 7, 7] [1, 128, 4, 4] 73,856
BatchNorm2d-15 [1, 128, 4, 4] [1, 128, 4, 4] 512
ReLU-9 [1, 128, 4, 4] [1, 128, 4, 4] 0
Conv2d-17 [1, 128, 4, 4] [1, 128, 4, 4] 147,584
BatchNorm2d-16 [1, 128, 4, 4] [1, 128, 4, 4] 512
Conv2d-18 [1, 64, 7, 7] [1, 128, 4, 4] 8,320
Residual-7 [1, 64, 7, 7] [1, 128, 4, 4] 0
Conv2d-19 [1, 128, 4, 4] [1, 128, 4, 4] 147,584
BatchNorm2d-17 [1, 128, 4, 4] [1, 128, 4, 4] 512
ReLU-10 [1, 128, 4, 4] [1, 128, 4, 4] 0
Conv2d-20 [1, 128, 4, 4] [1, 128, 4, 4] 147,584
BatchNorm2d-18 [1, 128, 4, 4] [1, 128, 4, 4] 512
Residual-8 [1, 128, 4, 4] [1, 128, 4, 4] 0
ResnetBlock-4 [1, 64, 7, 7] [1, 128, 4, 4] 0
Pool2D-4 [1, 128, 4, 4] [1, 128, 1, 1] 0
Linear-2 [1, 128] [1, 10] 1,290
Softmax-2 [1, 10] [1, 10] 0
================================================================================
Total params: 680,458
Trainable params: 677,130
Non-trainable params: 3,328
--------------------------------------------------------------------------------
Input size (MB): 0.00
Forward/backward pass size (MB): 0.84
Params size (MB): 2.60
Estimated Total Size (MB): 3.44
--------------------------------------------------------------------------------
{'total_params': 680458, 'trainable_params': 677130}
哇⊙∀⊙!酷
而且后来发祥网络权重也是可以打印滴~~
是用model.summary()这个方法吗
rnpt = ResNet()
param_info = paddle.summary(rnpt, (1, 28, 28), batch_size=1)
print(param_info)
只要定义模型对象就可,不需正向计算。
要输入一个初始特征图(即图片)尺寸就行了
懂了,这就去查summary这个属性