如何将一个 Functional Resnet50 模型分解为多层
How to break one Functional Resnet50 model into multiple layer
我使用以下方法创建了 Resnet50:
base_model = tf.keras.applications.ResNet50(include_top=False, weights=None, input_shape=(224, 224, 3))
base_model.trainable = True
inputs = Input((224, 224, 3))
h = base_model(inputs, training=True)
model = Model(inputs, projection_3)
模型摘要:
Layer (type) Output Shape Param #
=================================================================
input_image (InputLayer) [(None, 256, 256, 3)] 0
resnet50 (Functional) (None, 8, 8, 2048) 23587712
=================================================================
后来,我意识到我需要像这样访问一些层:
Resmodel.layers[4].output
然而,我得到了:
IndexError: list index out of range
是否可以将 Resnet50 功能模型分解为多个层或 是否可以访问模型的特定层。
试试这个
model.layers[1].layers[4]
我使用以下方法创建了 Resnet50:
base_model = tf.keras.applications.ResNet50(include_top=False, weights=None, input_shape=(224, 224, 3))
base_model.trainable = True
inputs = Input((224, 224, 3))
h = base_model(inputs, training=True)
model = Model(inputs, projection_3)
模型摘要:
Layer (type) Output Shape Param #
=================================================================
input_image (InputLayer) [(None, 256, 256, 3)] 0
resnet50 (Functional) (None, 8, 8, 2048) 23587712
=================================================================
后来,我意识到我需要像这样访问一些层:
Resmodel.layers[4].output
然而,我得到了:
IndexError: list index out of range
是否可以将 Resnet50 功能模型分解为多个层或 是否可以访问模型的特定层。
试试这个
model.layers[1].layers[4]