'What is the default pooling size of Max pooling layers in Keras?
What is the default pooling size of maxpooling layers in Keras? Pooling layers have 3 args: pool_size, strides and padding. If the pool_size is not explicitly specified, what pool_size value does Keras use by default?
For example in the following keras pooling layer, which is the pool_size?
model.add(tf.keras.layers.MaxPooling2D(strides=(2,2), padding='same'))
Solution 1:[1]
The default in Keras as it is in Tensorflow with the Keras backend is pool_size=(2,2), therefore it will halve the input's x and y spatial dimensions.
Here you can see the documentation in Tensorflow where it is mentioned.
To be more specific, the stride and pool_size arguments are highly related and differ only when you change the padding type. As mentioned in the documentation:
output_shape = math.floor((input_shape - pool_size) / strides) + 1 in the case where input_shape >= pool_size if the chosen padding is valid.
Otherwise, if chosen padding is same:
output_shape = math.floor((input_shape - 1) / strides) + 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jack Avante |
