3-Practical training. Convolutional neural networks (CNN) architecture, implementation of the convolution process.
Example:
Convolutional Neural Network (CNN): Forward Propagation
Convolution layer
Do you know how we determine the shape and edges of an object from images? A convolutional neural network does this by comparing pixel values.
The image below shows us the image of the number 8 and the pixel values that exactly correspond to this image (Figure 1). If we pay attention to the picture. We can notice that there is a significant difference between the pixel values around the edges of the figure and the pixel values in between. So, a simple way to determine the shape here is to compare the neighboring pixel value.
Figure 1. Image recognition by convolutional neural network (CNN).
What should we do in this process? Should we move pixel by pixel and compare these values? No! To obtain this information, the image is convoluted with a filter (also, the concept of the filter involved in this process is called a "kernel" in the mathematical model and is kept under this name).
Convolution is often represented mathematically by an asterisk *. If we have an input image value expressed as X and a filter (kernel) denoted by the letter f, then the expression is (1):
(1)
Let's try to explain the convolution process using a simple example. Suppose we are given a 3 x 3 image and a 2 x 2 filter (Figure 2).
Figure 2. 3 x 3 image and 2 x 2 filter.
The sequence of mathematical operations of this process can be explained as follows. The filter passes through slices containing certain cells of the image, multiplications are performed by the elements in these cells, and the values are summed: