29. Convolution - the role of parameter padding

In the convolution process, Padding is a key concept, which is crucial to retaining input information and effectively processing edge information.

1. What is Padding?

Padding refers to adding additional pixel values ​​around the input image to expand the size of the input image. These additional padding pixel values ​​are usually set to zero, and the convolution operation is performed on this padded input image.

As shown in the figure above, the process of a convolution operation is viewed from a top view. The top is the convolution kernel, and the process of sliding scanning on the blue image below.

Around the blue image, a circle of white pixels is filled, which is padding. In actual convolution calculations, padding does not necessarily only fill one circle, but may be two or three circles, and the number of padding in the four directions of up, down, left, and right may be different. For example, one row is padded on the left and two rows are padded on the right. This depends on the network structure.

2. Why is Padding needed?

Although padding is relatively simple and easy to understand, its role is not small. I have summarized that the main functions of padding are as follows.

prevents image edge information loss. When performing a convolution operation, the convolution kernel is generally a small window that slides on the input image.

If there is no padding, each time the convolution kernel is moved and calculated, the output size of the convolution will become smaller, which may eventually cause the edge information of the input image to be lost and fill the

Guess you like

Origin blog.csdn.net/dongtuoc/article/details/134898657