Why do convolutional filters use odd parity?

In deep learning models, convolutional filters are usually used to extract spatial features from the data. The use of odd-sized convolutional filters is common in these models. Most of the state-of-the-art architecture goes with this convention. In this answer, we will dive into the “why” of this convention.

What is a convolution operation in deep learning?

In deep learning, a convolution operation is used to encode the information of the input matrix in terms of filters or kernels. The mathematics behind the operation is simple. That is, a convolutional filter is multiplied by the input matrix element-wise. The following figure highlights the working of the convolution operation.

A convolution operation
A convolution operation

The same operation can be extended to a larger input matrix. In that case, however, the convolution operation can not be applied at once. The alternative is to apply the convolutional filter in a series of windows.

What should be the parity of the convolutional filter?

We have briefly discussed the convolution operation and how it can be applied to matrices of different sizes. Now, we will talk about determining the parityParity refers to a number being even or odd. of the convolutional filters. Although the size of filters can be even or odd, odd-sized filters offer the advantages of simplicity and symmetry.

  • Simplicity: The use of padding is very common in deep learning architectures. When adding ppp*p padding to the nnn*n input matrix, we want the resulting matrix to be in the nnn*n shape. The odd-sized convolutional filters keep the mathematics simple. The following is an equation for calculating the resulting size of a convolution operation:

Assuming that outputsizeoutput size equals inputsizeinput size, we get the following equation for paddingsizepadding size:

From the above equation, we can see how using even-sized filters will result in decimal padding sizes, therefore, causing aliasing errors. The code below can be used to test this.

# filter size is even.
filter_size = 6
padding_size = (filter_size-1)/2.0
print("Padding Size : " + str(padding_size))

Note: To get a better idea of padding, check out another Educative Answer on subsequent convolution layers.

  • Symmetry: In odd-sized filters, the matrices are symmetrically shaped, and therefore, each filter can be centered around an anchor point.

Symmetry of filters
Symmetry of filters

Conclusion

The use of odd-sized convolutional filters helps keep the padding simple and gives the output a symmetrical shape.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved