Padding

Create custom padding layers to maintain consistency in padding.

Chapter Goals:

  • Implement consistent padding based only on kernel size

A. Padding consistency

In the CNN section, we mentioned that TensorFlow uses the minimum amount of padding necessary when we set padding='same' for our convolution or pooling layers. However, the amount of padding used depends on the kernel size, stride size, and input height/width. This leads to inconsistent padding amounts at different layers of our model.

Since ResNet has so many layers and follows a repetitive structure, we want to maintain as much consistency as possible. Therefore, when we pad our data for a convolution layer, we want the padding to be solely based on the size of the kernel.

...