Machine Learning

How CNN works for image analysis by ON April 06 2019

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.

Image convert into 2D matrix

A. Convolutional Layer: In Convolutional move the features/filter to every possible position of the image and there are four steps to be performed in this layer.

1.Line up the feature and the image : First we need to decide the sliding window size for extracting the features from image.

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.

Extracting feature as per slide size

2. Multiply each image pixel by the corresponding feature pixel :-

Multiply the pixel value with 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.

Intermediate matrix to Convolutional layer O/p

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

Applying activation function

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
Pulling max value from window size 2×2

After this layer perform all above the layer again an again till the resultan matrix in not minimized.

This step frequently perform till get desired size matrix

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 .

Convert the feature matrix to list

After all the process prediction is happen like

Match the maximum predicted value from among the list.

Get highest value

Finally, an image is identified as “X” because its prediction value is higher than the other.

Thank you : >)

author's avatar ALL POST
Knowledge contribution is better than any contribution.

4 thoughts on “How CNN works for image analysis”

author's avatar
Reply Mayurkumar Bharatbhai Malaviya
April 10, 2019 at 12:03 pm

your blog is easy to understand for fresher


author's avatar
Reply http://www.formatnyc.com
September 11, 2019 at 4:55 am

I’m not sure why but this site is loading
extremely slow for me. Is anyone else having this problem
or is it a problem on my end? I’ll check back later and see if the problem still exists.


author's avatar
Reply decor
November 7, 2019 at 8:13 pm

Right away I am going away to do my breakfast, afterward
having my breakfast coming again to read further
news.


LEAVE A COMMENT

Leave a Reply

Your e-mail address will not be published. Required fields are marked *