Convolutional Neural Network

We offer you a brighter future with FREE online courses - Start Now!!

Till now, PythonGeeks has shared tremendous benefits of using Machine Learning. We’ve seen the various advancements that are possible because machines are now able to take human-like decisions too without human intervention. We’ve talked enough about the boons that exist because of Machine Learning. However, have you ever imagined how these machines are able to classify and learn all the information that we give to them? How are they able to make human-like decisions just on the basis of a few lines of code? How are we actually able to “train” these models to make near to perfect decisions?

In this PythonGeeks article, we are going to discuss one such application in detail. We will learn about how machines are able to classify the images given to them as an input on the basis of data that we feed to them. How are these machines able to tell a cat apart from a dog or how are they able to suggest you a friend on social media just by “looking” at the pictures you post?

The answer to all these questions is quite simple- CNN. We will see what actually is this CNN, its working designs, and its applications in the following article. So, now that you have the overview of the article, let’s begin to learn about our first neural network algorithm- CNN.

Introduction to Convolutional Neural Network

Convolutional Neural Network, more commonly referred to as CovNet is a feed-forward neural network that is used for image classification and processing with the help of provided data. A convolutional neural network tends to classify the various objects that it “sees” in the provided image. It works on the principle of the structured array, where the array elements are the segments of the specified image. The following image demonstrates how the algorithm stores an image in the form of an array of pixelated values.

introduction to convolutional neural network

With this array, the algorithm tends to store the various features of the image in the array. Each element in the image will have a unique array of features as demonstrated above. The algorithm then processes the stored information to attain more information about any object in the image. This technique assists the algorithm in distinguishing one object from the other.

For example, if we provide the algorithm with the image of a cat, then the algorithm will store the information about this cat in the form of such an array. Thus, next time you feed the algorithm with cat pictures, it looks into its database and finds similarities to the given picture. Thus, it is able to identify any object that the algorithm processes through it.

This makes CNN a robust and reliable algorithm in classifying and processing images. It is quite suitable when it comes to choosing and designing input images from a wide arena ranging from lines, circles to even human faces. This minimal effort also helps the algorithm in processing underdone images with precision as well.

The power of this algorithm lies in the fact it is quite autonomous. Simply, once you provide primary data to the algorithm, it pre-processes the information by itself. Though it requires some human interference in the beginning to feed this data, it is able to acquire proper training from the data and adapts its learning methods according to the features. This helps CNN in developing its filters on an exponential basis.

Now that you know the basics of how Machine Learning is able to classify and process images with the help of CNN, let us look at the architecture of this algorithm. Learning about basic design will help us to understand working in a much better and more comprehensive way.

Architecture of CNN

As we already discussed earlier, CNN is a feed-forward neural network. It achieves these incredible results with its inbuilt layers. CNN consists of 5 main layers that are compiled on top of each other. These layers help in processing and retrieving data easily from the image. Let us discuss them in brief.

1. Input Layer

This is the starting layer of the algorithm. We feed it a raw image with the dimensions 32x32x3. Here, the dimension is specified in the format width x height x depth.

2. Convolutional Layer

After taking the image as an input, this is the first step in processing and extracting valuable information from the image. As we discussed earlier, an image is a matrix of pixelated values. The convolutional layer performs the convolutional operation on the image with the help of the various filter layers present in it. It outputs the dot product of the filter matrix and the image information. Here, the dimensions become 32x32x12.

3. ReLu Layer

ReLu is the shorthand notation for rectified linear units. Once the image is passed through the convolutional layer, the extracted information moves to the ReLu layer. This layer’s job is to set 0 value to all the negative pixels of the image. The reason that it is called a rectified linear unit is that it converts the result into a non-linear rectified feature map. The main function of this layer is to filter out the features of the image. The dimensions of the image

4. Pooling Layer

This is the dimensionality reduction step of the algorithm. After rectification, the image moves to the pooling layer for a down-sampling operation. This layer passes the rectified layer through the pooling layer to generate a pooled feature map. The main feature of this layer is to identify different parts of the extracted features like corners, edges, eyes, feathers, etc. The dimensions of the image now become 36x36x1.

5. Fully Connected Layer

 

The next and final step in image processing is flattening the image. This layer creates a single 1-dimensional vector from the 2-dimensional matrix pooled image. This vector is then helpful for image classification.

fully connected layer

Working of CNN

The working mechanism of CNN is quite similar to that of a normal Neural Network. Each neuron present in the architecture of the CNN is responsible for performing the dot product of the input as soon as we pass the input to the network. At the end of the architecture, a singular differentiable score function is present which is responsible for the processing of the input that we acquire from the input stage. We acquire the scores present in this function from the previous layers of the convolutional neural network.

A loss function at the end helps us to evaluate the overall result that we get at the end. The primary difference in the working of a common neural network and that of a Convolutional Neural Network is that CNN explicitly assumes that we will provide it with an image for its input. This assumption proves beneficial for the network as the arrangement of neurons remains unaffected. This helps the network in achieving seemingly accurate results and makes it more reliable.

Applications of CNN

1. CNN was predominantly built for image classification and processing, and hence, it is used mostly in the field of computer vision. They are quite effective when it comes to image segmentation, localization of the image, and classifying them accordingly. Similarly, we can apply it to video processing as well. Though videos aren’t the same as images as they are quite complicated to handle. CNN can be modified in such a way that they can handle the video inputs quite efficiently.

2. Apart from the usual image processing, CNNs are a great tool in Natural Language Processing (NLP). Through CNN, we can operate various NLP programs like language semantics, sentence modeling, and classification. In a much recent advancement, major names in the tech world are deploying CNN alongside RNN and LSTM for speech recognition alongside image classification.

3. CNN’s are quite new in the field of healthcare. Though less exploited, CNN can be a great aid in discovering new drugs for treating various ailments. They are efficient in identifying the interconnecting link between biomolecules and potential drug trails.

4. CNN finds its presence in the field of Diabetic Retinopathy. It is basically an optical ailment that affects the retina due to diabetic Mellitus. CNN is much more effective in the detection of this Mellitus in comparison to the conventional tools we use today.

Conclusion

Hence, we’ve come to the conclusion of this article. We came to know how popular and efficient this Machine Learning algorithm is in the field of image classification. We also came across ways in which apart from image classification, we can use CNN for numerous other works. Then we saw how the CNN algorithm works in-depth working of the CNN algorithm with the help of its architecture. Thus, we came to know about CNN in a brief and comprehensive way.

Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google | Facebook


1 Response

  1. M MUTHURAMALINGAM says:

    Respected Sir
    very useful for me

Leave a Reply

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