I am using the Keras functional API and I am confused about the output.
model = tf.keras.applications.ResNet50(include_top = False,
weights = None,
input_shape = (100,100,3),
pooling = 'max',
classifier_activation = 'relu')
layer_outputs = [layer.output for layer in model.layers[:15]]
model2 = tf.keras.models.Model(model.input, layer_outputs)
model2.summary()
_________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
=================================================================================
input_13 (InputLayer) [(None, 100, 100, 3) 0
_________________________________________________________________________________
conv1_pad (ZeroPadding2D) (None, 106, 106, 3) 0 input_13[0][0]
_________________________________________________________________________________
conv1_conv (Conv2D) (None, 50, 50, 64) 9472 conv1_pad[0][0]
_________________________________________________________________________________
conv1_bn (BatchNormalization) (None, 50, 50, 64) 256 conv1_conv[0][0]
_________________________________________________________________________________
conv1_relu (Activation) (None, 50, 50, 64) 0 conv1_bn[0][0]
_________________________________________________________________________________
pool1_pad (ZeroPadding2D) (None, 52, 52, 64) 0 conv1_relu[0][0]
_________________________________________________________________________________
pool1_pool (MaxPooling2D) (None, 25, 25, 64) 0 pool1_pad[0][0]
_________________________________________________________________________________
conv2_block1_1_conv (Conv2D) (None, 25, 25, 64) 4160 pool1_pool[0][0]
_________________________________________________________________________________
conv2_block1_1_bn (BatchNormali (None, 25, 25, 64) 256 conv2_block1_1_conv[0][0]
________________________________________________________________________________
conv2_block1_1_relu (Activation (None, 25, 25, 64) 0 conv2_block1_1_bn[0][0]
_________________________________________________________________________________
conv2_block1_2_conv (Conv2D) (None, 25, 25, 64) 36928 conv2_block1_1_relu[0][0]
_________________________________________________________________________________
conv2_block1_2_bn (BatchNormali (None, 25, 25, 64) 256 conv2_block1_2_conv[0][0]
_________________________________________________________________________________
conv2_block1_2_relu (Activation (None, 25, 25, 64) 0 conv2_block1_2_bn[0][0]
_________________________________________________________________________________
conv2_block1_0_conv (Conv2D) (None, 25, 25, 256) 16640 pool1_pool[0][0]
_________________________________________________________________________________
conv2_block1_3_conv (Conv2D) (None, 25, 25, 256) 16640 conv2_block1_2_relu[0][0]
=================================================================================
Total params: 84,608
Trainable params: 84,224
Non-trainable params: 384
input_anchor = tf.keras.layers.Input(shape = (100,100,3))
input_positive = tf.keras.layers.Input(shape = (100,100,3))
input_negative = tf.keras.layers.Input(shape = (100,100,3))
embedding_anchor = model2(input_anchor)
embedding_positive = model2(input_positive)
embedding_negative = model2(input_negative)
output = tf.keras.layers.concatenate([embedding_anchor[0],
embedding_positive[0],
embedding_negative[0]] , axis = -1)
siamese = tf.keras.models.Model([input_anchor, input_positive, input_negative], output)
siamese.summary()
_________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
=================================================================================
input_32 (InputLayer) [(None, 100, 100, 3) 0
_________________________________________________________________________________
input_33 (InputLayer) [(None, 100, 100, 3) 0
_________________________________________________________________________________
input_34 (InputLayer) [(None, 100, 100, 3) 0
_________________________________________________________________________________
model_5 (Functional) [(None, 100, 100, 3) 84608 input_32[0][0]
input_33[0][0]
input_34[0][0]
_________________________________________________________________________________
concatenate_7 (Concatenate) (None, 100, 100, 9) 0 model_5[15][0]
model_5[16][0]
model_5[17][0]
=================================================================================
Total params: 84,608
Trainable params: 84,224
Non-trainable params: 384
What I am confused about is why is my output is (None,100,100,9) when I thought it would be (None,25,25,768). I have a feeling is something to with my model2 but I have no idea how to get the correct shape. Any help is much appreciated.


