Padding adds a border of extra values—usually zeros—around an input image or tensor before convolution. It gives a filter room to reach edge and corner pixels instead of hanging outside the input. section 12.14
Padding is useful when a convolution should:
- Preserve spatial size, allowing the output feature map to keep the input’s height and width. section 12.14
- Process borders properly, so features near edges are not lost or represented less often during training. section 12.14
A 3×3 filter at an image corner
Without padding, a 3×3 filter centered on a corner would extend beyond the image. With one layer of zero padding, the filter can start at the top-left position, multiply its values by the available pixels and added zeros, sum the results, and continue scanning every original pixel. With stride 1 and the right amount of padding, the output retains the input dimensions. section 12.14


















