Course 4 Week 1 Assignment-2 Functional API Maxpool2D

It’s reasonable to think that “same” padding would produce the same output dimensions, but it turns out that’s not the way it works at least in TensorFlow. It turns out that “same” padding only gives the same output dimensions when stride = 1. They explain this on the docpage for MaxPool2D.

It turns out this is true with Conv2D layers as well as pooling layers, although the docpage is maybe a little misleading in that it does not mention the effect of stride. Try it and see. The dimensions are only preserved if stride = 1 and padding = “same”. If you say padding = “same” and stride = 2, the dimensions definitely are not preserved.

Here’s a thread which delves into this in more detail. It turns out that there is a serious reason why they implement “same” padding this way.