Zero-padding is a very simple concept that we apply to the border of our input. With a stride of 1, the output of the feature map will be a 3 x 3 matrix. We can see that after applying a stride of 1, we end up with a tiny output. This output will be the input for the next layer. In this way, there are high chances of losing information. So, we add a border of zeros around the input, as shown in the following screenshot:
Adding zeros around the border is equivalent to adding a black border around an image. We can also set the padding to 2 if required.
Now, we will calculate the output of the convolution mathematically. We have the following parameters:
- Kernal/filter size, K
- Depth, D
- Stride, S
- Zero-padding, P
- Input image size, I
To ensure that the filters cover the full input image symmetrically, we'll use the following equation to do the sanity check; it is valid if the result of the equation is an integer:
In the next section, we will...