I would like to add "GlobalAveragePooling2D" and Predication (Dense) to my base ResNet50. As show below
So I did this:
x=base_model.output
x = tf.keras.layers.GlobalAveragePooling2D()(x)
x = tf.keras.layers.Dense(2, activation='softmax')(x)
model = keras.models.Model(inputs=base_model.input, outputs=x)
model.summary()
But I got this:
Are they different or the same, because I think I got different results.
CodePudding user response:
They are the same only difference is that you did not give any name to your layers. The summary will be same if you do it like:
x = base_model.output
x = tf.keras.layers.GlobalAveragePooling2D(name = 'avg_pool')(x)
x = tf.keras.layers.Dense(2, activation='softmax', name = 'predictions')(x)
model = tf.keras.models.Model(inputs=base_model.input, outputs=x)
model.summary()