user836026
user836026

Reputation: 11350

Adding GlobalAveragePooling2D to ResNet50

I would like to add "GlobalAveragePooling2D" and Predication (Dense) to my base ResNet50. As show below

enter image description here

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:

enter image description here

Are they different or the same, because I think I got different results.

Upvotes: 0

Views: 909

Answers (1)

Frightera
Frightera

Reputation: 5079

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()

Upvotes: 1

Related Questions