CNN – Padding
Syllabus:
- What Is Padding In CNN?
- Why We Use Padding?
- Types Of Padding.
- Examples Of Padding.
- Key Points.
(1) What Is Padding In CNN?
- Padding in Convolutional Neural Networks (CNNs) refers to adding extra pixels (usually zeros) around the edges of an input image or feature map.
- The purpose of padding is to control the spatial dimensions of the output feature map after applying a convolution operation.
(2) Why We Use Padding?
(3) Types Of Padding.
(4) How Much Padding We Should Do Such That The Input & Output Size Will Be Same.
- The Formula for Output Size = (Input Size – Kernel Size) + 1
- For an image of size 5*5 if we want the output also to be 5*5 what should be the padded value or how much we should increase the image size.
- Take a filter of 3*3 size.
- Output Size = (Input Size – Kernel Size) + 1
- We want Output Size = 5
- What should be the Input Size = ?
- 5 = (Input Size – Kernel Size) + 1
- 5 = (Input Size – 3) + 1
- 5 = Input Size – 2
- Input Size = 5 + 2 = 7
- Input Size = 7.
- Hence Input Size should be 7 * 7.
(5) Example Of Padding
- Padding in Convolutional Neural Networks (CNNs) involves adding pixels (usually zeros) around the border of an input image or feature map.
- Here’s a detailed walkthrough of an example:

