## MAXPOOL: window 8x8, stride 8, padding 'SAME'

MAXPOOL: window 8x8, stride 8, padding ‘SAME’

why are we use padding in pooling?isn’t it negating the effect of pooling?

Hello @karra1729
The whole purpose of pooling layers is to reduce the spatial dimensions (height and width). Therefore, padding is not used to prevent a spatial size reduction like it is often for convolutional layers. Instead padding might be required to process inputs with a shape that does not perfectly fit kernel size and stride of the pooling layer.

This is an example where it perfectly fits and your pooling layer does not require any padding: Pooling with kernel size 2x2, stride 2, no padding

Side note: The output dimensions are calculated using the usual formula of O=I−K+2PS+1O=I−K+2PS+1 with II as input size, KK as kernel size, PP as padding and SS as stride.

However, lets take another example where it does not fit as nicely:

Pooling with kernel size 2x2, stride 2 and padding

Here you need padding since your input size is not an integer multiple of your kernel size. Therefore, you need to add padding on one side in order make it work.

So padding="same" in Keras does not mean the spatial dimensions do not change. It just means that padding is added as required to make up for overlaps when the input size and kernel size do not perfectly fit.