我正在尝试为给定(通用)模型选择最后一个Conv2D层。 model.summary()
提供了具有其类型的图层列表,但是如何访问该列表以找到该类型的图层?
model.summary()
的输出:
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, 224, 224, 3) 0
_________________________________________________________________
block1_conv1 (Conv2D) (None, 224, 224, 64) 1792
_________________________________________________________________
...
_________________________________________________________________
predictions (Dense) (None, 1000) 4097000
=================================================================
Total params: 138,357,544
Trainable params: 138,357,544
Non-trainable params: 0
答案 0 :(得分:4)
我认为您正在寻找的是这个
layer.__class__.__name__
图层位于
model.layers
答案 1 :(得分:2)
您可以以相反的顺序遍历ID N
1 3
2 2
3 1
并通过model.layers
检查图层类型:
isinstance