Convolutional Neural Networks (CNN) are a type of feedforward neural network that includes convolutional computations and has a deep structure. They are one of the representative algorithms of deep learning. This article aims to introduce the basic concepts and structures of CNN, as well as the fundamental ideas behind CNN architecture design.
This article is packed with valuable content, suitable for saving!
【1】Introduction
No more unnecessary talk, let’s get started.
When we get an image and need to recognize it, the simplest example is to ask: what is this image?
For instance, I want to train the simplest CNN to recognize whether a letter in an image is X or O.
When we look at it, it seems very simple; obviously, it is X. However, the computer does not know what X is. So we label this image, commonly known as a Label, with Label=X, which tells the computer that this image represents X. It remembers what X looks like.
But not all X’s look like this. For example…

These four are all X, but they look obviously different from the previous X. The computer has never seen them and does not recognize them.
(Here we can mention a term that sounds very sophisticated in machine learning: “underfitting”)
What to do if it doesn’t recognize them? Of course, it should recall if it has seen something similar. At this point, what CNN needs to do is to extract the features of images that represent X.
We all know that images are stored in the computer in terms of pixel values, meaning that two X’s actually look like this to the computer.


Where 1 represents white, and -1 represents black.
If we compare each pixel one by one, it is definitely unscientific, the results will be wrong and the efficiency will be low, so other matching methods are proposed.
We call this patch matching.
Observing these two X images, we can see that despite the pixel values not corresponding one by one, there are still some common points.
As shown in the above image, the structure of the three same-colored areas in both images is completely consistent!
Therefore, we consider whether we can relate these two images. While we cannot correspond all pixels, can we match them locally?
The answer is certainly yes.
If I want to locate a face in a photo, but CNN does not know what a face is, I tell it: a face has three features, what the eyes, nose, and mouth look like, and then tell it what these look like. As long as CNN searches the entire image and finds where these three features are located, it has located the face.
Similarly, we extract three features from the standard X image.




We find that using these three features can locate a certain part of X.

Features in CNN are also called convolution kernels (filters), usually sized 3X3 or 5X5.
【2】Convolution Operation
After talking for so long, we finally get to the word convolution!
But!! Friends! The convolution operation in convolutional neural networks has nothing to do with the convolution operation in signal processing! At one point, I even reviewed the convolution operation from higher mathematics! Ugh!
These!! have nothing to do with our CNN!!!
Alright, let’s continue discussing how to calculate. Four words: corresponding multiplication. Look at the diagram.
Take the (1,1) element value from the feature, and take the (1,1) element value from the blue box in the image, multiplying the two gives 1. Fill this result of 1 into the new image.


Similarly, continue calculating the values at the other 8 coordinates

Once all 9 are calculated, it will look like this.

The next task is to average the nine values on the right, get a mean, and fill the mean into a new image.
This new image is called the feature map.

Some children might want to ask, why does the blue box have to be placed in this position on the image?
This is just an example. This blue box is called a “window,” and its characteristic is that it can slide.
Actually, it should start at the initial position.

After performing the convolution corresponding multiplication operation and calculating the mean, the sliding window starts to slide to the right. Depending on the stride, the sliding amplitude is selected.
For example, if the stride is 1, it moves right by one pixel.
If the stride is 2, it moves right by two pixels.
After moving to the far right, it returns to the left and starts the second row. Similarly, if the stride is 1, it moves down by one pixel; if the stride is 2, it moves down by two pixels.
Alright, after a series of convolution corresponding multiplication and averaging operations, we finally filled a complete feature map.
The feature map is the “feature” extracted from the original image by each feature. The closer the value is to 1, the more complete the match with the corresponding position and feature; the closer it is to -1, the more complete the match with the opposite of the feature, while values close to 0 indicate no match or little correlation.
One feature produces a feature map for the image, and for this X image, we used three features, so we ultimately produced three feature maps.

Thus, the convolution operation part is complete!~
Finally, I have compiled a resource package on artificial intelligence learning, scan the code to obtain~
Huaqing Yuanshen
Helping many students realize their IT dreams
Achieve high salary dreams
Scan for surprises↑↑↑
Don’t forget to share good things~

