I am writing this article for the best learner reader who wants to know about CNN and it’s layer so this article will help you to understand the CNN layers and how it’s work in each layer with example .
Convolutional neural network (CNN):- A CNN is composed of a series of layers, where each layer defines a specific computation. The Neural Network provides functionality to easily design a CNN layer-by-layer.
There are main four layers in the convolutional neural network.
A. Convolutional Layer
B. Rectified Linear unit Layer
C. Max Pooling Layer
D. Fully Connected Layer
Let take a example to understand how computer understand the image.
Basically a computer understand an image using numbers at each pixel .
In our example, we have taken an image of ‘X’ that consider the value of each pixel that a black pixel will have value 1 and a white pixel will have -1 value.
A. Convolutional Layer: In Convolutional
1.Line up the feature and the
Example : here sliding window is 3X3 .
We can see the below image there are some features extracted from another image X which are equal to a feature of original image X.
2. Multiply each image pixel by the corresponding feature pixel :-
3. Add them up: Whatever intermediate matrix get from the previous step we will add the result of each cell and pass to the next step.
4. Divide by the total number of pixel in the features: Here the added value is divided by the total number of cell in the matrix and the result will be stored in a next intermediate matrix that is called the output of Convolutional layer.
B. Rectified Linear unit Layer (ReLU) : – ReLU transform function only activates a cell if the input is above a certain quantity , while the input is below 0 the output is 0 , but when input rises above a certain threshold ,it has a linear relationship with dependent variable .
In this layer removed every negative values from filtered image and replace it with 0.
Function :- f(x) = max(0,x)
0 : X < 0
1 : X > 0
C. Max Pooling Layer: In this layer shrink the matrix stack into a smaller size.
For getting some result we need to perform some steps:
- Pick a window size (usually 2×2 or 3×3 )
- Picked a stride size (usually 2)
- Move the window across the filtered matrix (Output of ReLU layer)
- From each window take the maximum values
After this layer perform all above the layer again an again till the
D. Fully Connected Layer :- This is the final layer where the actual classification happens .
Here take our filtered and shrinked matrix and put in into single list .
After all the process prediction is happen like
Match the maximum predicted value from among the list.
Finally, an image is identified as “X” because its prediction value is higher than the other.
Thank you : >)