Friday, August 20, 2021

Implementation of Convolution Neural Network

 Convolution Neural Network


Convolution Neural Network is a class of Artificial Neural Network which is a learning algorithm used in deep learning. So why CNN and what is its applications? 

CNN is mostly used in applications like :

  • Image Classification
  • Object detection
  • Neural StyleTransfare

So, for example, say you have an image of a cat and you want to build an AI that can detect that picture is a Cat, 1st thing to think about is using CNN because of its performance in image detection application and in brief you will know why.


As you have known CNN is a class of ANN that is basically an AI learning algorithm, but why will you 1st think about it and not any other learning algorithm

If you are familiar with other learning algorithms like leaner regression for example after applying it for some application and it gave you output and you retry to use the algorithm again on the same dataset and application it will give you the same output 💯

But if you use ANN and its family each time you use the algorithm the output is different because it has a learning rate that is different each time you enter input, that is why you choose ANN for some applications because you don't want each time you enter a cat image, for example, the AI recognize it as it did in the first time which will always be far from right.


How CNN works?

Image from Medium

Like I have mentioned earlier if you have an image of a cat and you want the CNN to identify the image as a cat, 1st thing the NN will do is to detect the edges in the image by applying a vertical or horizontal edge detection filter





So applying this filter will show the vertical edges of an image, making the darker parts more clear and white parts clear on some sides.

Applying the filter is called convoluting, and there are many types of edge detection filters like Sobel, Schorr filter, and so on. These filters have values that are fixed and they found that these values can be learned using the NN to make the detection more clear and it is done on the RGB image.







Some issue that faces CNN work is if the image is too small applying the filter will already reduce the size of an image like the image above it (6 * 6 * 3) after applying the  filter it became (4 * 4), so one solution to this problem is Padding.

Padding as the name imply is adding more pixels around the image so after applying the filter it does not shrink.

Types of Layers in CNN:
  1. Convolution
  2. Pooling
  3. Fully Connected

The pooling layer is used to reduce the convoluted output of the Conv. layer.



After applying the filters on the RGB image it becomes a bigger representation so it can reach sometimes  (3000 * 3000 * 1000) and that is another challenge of CNN already, so we use padding to reduce the representation by applying a layer of pooling.

Pooling also has other types like Average pooling or Max pooling we don't want to dive into details here just the general idea of how CNN works.

How to implement CNN to identify your friend face or to detect an object :

Here is a good tutorial on github to impelement your CNN.






No comments:

Post a Comment

Don't miss the Blogger, contact them :)

Wireless Sensor Network integration to cloud service for data sharing

Wireless Sensor Network integration to cloud service for data sharing The basic idea of the prototype is to implement the basic  concept of ...