DLS course 4 image segmentation assignment max pooling 2D strides

Hello!

I have a small question about the max pooling output size while solving the image segmentation assignment!

How/why does the output size decrease by half after the maxPooling2D layer without strides argument?

Here is the code:

    # if max_pooling is True add a MaxPooling2D with 2x2 pool_size
    if max_pooling:
        ### START CODE HERE
        next_layer = MaxPooling2D(pool_size = (2,2))(conv)
        ### END CODE HERE

and the output size summary from the test code:

input_size=(96, 128, 3)
n_filters = 32
inputs = Input(input_size)
cblock1 = conv_block(inputs, n_filters * 1)
model1 = tf.keras.Model(inputs=inputs, outputs=cblock1)

output1 = [['InputLayer', [(None, 96, 128, 3)], 0],
            ['Conv2D', (None, 96, 128, 32), 896, 'same', 'relu', 'HeNormal'],
            ['Conv2D', (None, 96, 128, 32), 9248, 'same', 'relu', 'HeNormal'],
            ['MaxPooling2D', (None, 48, 64, 32), 0, (2, 2)]]

You see that there is no strides argument in maxPool2D layer. I tried to find the reason in tf documentation. The default strides argument is None

How does the default strides=None give us the effect as if it has strides = 2 ?

Thank you!

  • strides : Integer, tuple of 2 integers, or None. Strides values. Specifies how far the pooling window moves for each pooling step. If None, it will default to pool_size .

Here is the correct reference link:

MaxPool2D and MaxPooling2D seem to have different documentation.

ohhhh

I am not still used to read the document… Id rather read the documents more carefully…

Thank you for the replay!