CS Electrical And Electronics
@cselectricalandelectronics
All PostsDeep Learning, Machine Learning, & Artificial IntelligenceProgrammingWhat Is

What Is CNN Or Convolution Neural Network, Classification Of X And O

Hello guys, welcome back to my blog. In this article, I will discuss what is CNN(Convolution Neural Network), how a computer reads an image, why not fully connected networks for image recognition, how convolutional neural network works, etc. Each and everything I will try to explain in a simple way.

If you have any doubts related to electrical, electronics, and computer science, then ask questions. You can also catch me on Instagram – CS Electrical & Electronics And Chetan Shidling. 

Also, read:

What Is CNN Or Convolution Neural Network

How Computer Reads An Image?

What Is CNN Or Convolution Neural Network

The above image shows how the computer reads an image. The above image consists of three channels R, G, and B. Therefore, the size of the image should be (A*B*3). This is how the computer reads an image.  

Why Not Fully Connected Networks?

Why Not Fully Connected Networks?

The fully connected network is not used because as you can see in the above image, for an image with 28*28*3 pixels, the number weights in the first hidden layer will be 2352, and if the size of 200*200*3 pixels, the number of weights in the first hidden layer will be 120,000. therefore if the network has a large number of the parameter will suffer from a problem such as chances of overfitting, slower training time, etc. So, CNN is used because it reduces the image matrix to the lower dimension.  

Why Convolutional Neural Network?

Why Convolutional Neural Network?

The Convolutional Neural Network architecture is used for the analysis of images from the past few years. It is specially designed to process pixel data. By using CNN technic the image dimension can be reduced and the system output will be accurate.

What Is Convolutional Neural Network?

The Convolutional Neural Network is one of the popular architecture. The CNN consists of some layers such as convolution, pooling, ReLU, fully connected. With the help of a convolutional neural network, we can use a large amount of data more accurately and effectively.

How does CNN(Convolutional Neural Network) Work?

CNN has the following layers:  

01. Convolution

02. ReLU Layer

03. Pooling

04. Fully Connected

Let’s take the example of X and O images and learn how CNN works.

 X and O image and learn how CNN works

The images X and O will always be not the same, they sometimes look different which is very challenging for us as you see in the below image.

X and O will always be not the same

The CNN figure out whether the image is X or O by computing some steps. If the input image is X then it classifies X as output.

If the input image is X then it classifies X as output

Well, guys, I will give one image of X. The computer understands an image using numbers at each pixel. In this example, I will consider the black pixel will have a value of 1 and the white pixel will have a value of -1.

black pixel will have a value of 1 and the white pixel will have a value of -1

Using some techniques, the computer compares these images.

The Convolution Neural Network compares the piece of the image by piece. The pieces that it looks for are called features. By finding rough feature matches, in roughly the same position in two images, CNN gets a lot better at seeing similarity than whole image matching schemes.

Convolution Neural Network

These are small pieces of the bigger image. We choose a feature and put it on the input image if it matches then the image is classified correctly.

01. Convolution Layer 

Here we will move the feature/filter to every possible position on the image. Step -1: Line up the feature and the image. Step -2: Multiply each image pixel by the corresponding feature pixel.  

Multiplying the corresponding pixel values.

Multiplying the corresponding pixel values.
Multiplying the corresponding pixel values

Adding and Dividing by the total number of pixels.

Adding and Dividing by the total number of pixels
Adding and Dividing by the total number of pixels

Now, use the same feature move it to another location and perform the filtering again.

Now we will put the value of the filter at that position. Similarly, we will move the feature to every other position of the image and will see how the feature matches that area. Finally, we will get an output as:

Sliding the filter throughout the image
Sliding the filter throughout the image
Convolution layer
Convolution layer
Convolution layer output
Convolution layer output

02. ReLU Layer

In the Rectified Linear Unit, in this layer, we remove every negative value from the filtered images and replace it with zero’s. This is done to avoid the values from summing up to zeros.

Moving the window across the entire image
The output of one feature
Output After Passing Through Pooling Layer
The output of all features

03. Pooling Layer

Steps:

In this layer, we shrink the image stack into a smaller size.

a. Pick a window size (usually 2 or3).

b. Pick a stride (usually 2).

c. Walk your window across your filtered images.

d. From each window, take the maximum value.  

Let’s perform pooling with a windows size 2 and a stride 2.

Moving the window across the entire image
Moving the window across the entire image
Output after passing through pooling layer
Stacking up the layers
Stacking up the layers
Stacking up the layers
Stacking up the layers

04. Fully Connected Layer

This is the final layer where the actual classification happens. Here we take our filtered and shrunk images and put them into a single list.  

Fully connected layer
Fully connected layer

When we feed in,’ X’ and “O”. Then there will be some element in the vector that will be high. Consider the image below, as you can see for ‘X’ there are different elements that are high, and similarly, for ‘O’ we have different elements that are high.  

When we feed in,' X' and "O"

Consider the below list of new input images.

Consider the list of a new input image
Consider the list of a new input image

Let’s compare with X & O and check the output.

Comparing input vector with O
Comparing input vector with O
Comparing input vector with x
Comparing input vector with x

The input image is classified as X.

Result In CNN
Result In CNN

I hope this article “What Is CNN Or Convolution Neural Network” may help you all a lot. I think now you are clear with What Is CNN Or Convolution Neural Network, Classification Of X And O. Thank you for reading.

Also, read:

Tag: What Is CNN Or Convolution Neural Network, What Is CNN Or Convolution Neural Network, What Is CNN Or Convolution Neural Network, What Is CNN Or Convolution Neural Network, What Is CNN Or Convolution Neural Network, What Is CNN Or Convolution Neural Network, What Is CNN Or Convolution Neural Network.

Author Profile

CS Electrical And ElectronicsChetu
Interest's ~ Engineering | Entrepreneurship | Politics | History | Travelling | Content Writing | Technology | Cooking
Share Now

CS Electrical And Electronics

Interest's ~ Engineering | Entrepreneurship | Politics | History | Travelling | Content Writing | Technology | Cooking

Leave a Reply

Your email address will not be published. Required fields are marked *