Padding

With the convolution operation, we are sliding over the input matrix with a filter matrix. But in some cases, the filter does not perfectly fit the input matrix. What do we mean by that? For example, let's say we are performing a convolution operation with a stride of 2. There exists a situation where, when we move our filter matrix by two pixels, it reaches the border and the filter matrix does not fit the input matrix. That is, some part of our filter matrix is outside the input matrix, as shown in the following diagram:

In this case, we perform padding. We can simply pad the input matrix with zeros so that the filter can fit the input matrix, as shown in the following diagram. Padding with zeros on the input matrix is called same padding or zero padding:

Instead of padding them with zeros, we can also simply discard the region of the input matrix where the filter doesn't fit in. This is called valid padding:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset