0% found this document useful (0 votes)
3 views10 pages

Understanding of Convolutional Neural Network (CNN) - Deep Learning - by Prabhu Raghav - Medium

The document provides an overview of Convolutional Neural Networks (CNNs), which are primarily used for image recognition and classification tasks. It explains the structure and function of CNNs, detailing layers such as convolution, pooling, and fully connected layers, along with operations like strides and padding. The summary includes the process of inputting an image, applying filters, and classifying the output using activation functions.

Uploaded by

Gowtham Don
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views10 pages

Understanding of Convolutional Neural Network (CNN) - Deep Learning - by Prabhu Raghav - Medium

The document provides an overview of Convolutional Neural Networks (CNNs), which are primarily used for image recognition and classification tasks. It explains the structure and function of CNNs, detailing layers such as convolution, pooling, and fully connected layers, along with operations like strides and padding. The summary includes the process of inputting an image, applying filters, and classifying the output using activation functions.

Uploaded by

Gowtham Don
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Get unlimited access to the best of Medium for less than $1/week.

Become a member

Understanding of Convolutional Neural Network (CNN) — Deep Learning


5 min read · Mar 4, 2018

Prabhu Raghav Follow

Listen Share More

In neural networks, Convolutional neural network (ConvNets or CNNs) is one of the main categories to do images recognition, images classifications.
Objects detections, recognition faces etc., are some of the areas where CNNs are widely used.

CNN image classifications takes an input image, process it and classify it under certain categories (Eg., Dog, Cat, Tiger, Lion). Computers sees an input
image as array of pixels and it depends on the image resolution. Based on the image resolution, it will see h x w x d( h = Height, w = Width, d = Dimension ).
Eg., An image of 6 x 6 x 3 array of matrix of RGB (3 refers to RGB values) and an image of 4 x 4 x 1 array of matrix of grayscale image.
Figure 1 : Array of RGB Matrix

Technically, deep learning CNN models to train and test, each input image will pass it through a series of convolution layers with filters (Kernals), Pooling,
fully connected layers (FC) and apply Softmax function to classify an object with probabilistic values between 0 and 1. The below figure is a complete flow
of CNN to process an input image and classifies the objects based on values.

Figure 2 : Neural network with many convolutional layers

Convolution Layer

Convolution is the first layer to extract features from an input image. Convolution preserves the relationship between pixels by learning image features
using small squares of input data. It is a mathematical operation that takes two inputs such as image matrix and a filter or kernel.

Figure 3: Image matrix multiplies kernel or filter matrix

Consider a 5 x 5 whose image pixel values are 0, 1 and filter matrix 3 x 3 as shown in below

Figure 4: Image matrix multiplies kernel or filter matrix

Then the convolution of 5 x 5 image matrix multiplies with 3 x 3 filter matrix which is called “Feature Map” as output shown in below

Figure 5: 3 x 3 Output matrix

Convolution of an image with different filters can perform operations such as edge detection, blur and sharpen by applying filters. The below example
shows various convolution image after applying different types of filters (Kernels).
Figure 7 : Some common filters

Strides

Stride is the number of pixels shifts over the input matrix. When the stride is 1 then we move the filters to 1 pixel at a time. When the stride is 2 then we
move the filters to 2 pixels at a time and so on. The below figure shows convolution would work with a stride of 2.

Figure 6 : Stride of 2 pixels

Padding

Sometimes filter does not fit perfectly fit the input image. We have two options:

Pad the picture with zeros (zero-padding) so that it fits

Drop the part of the image where the filter did not fit. This is called valid padding which keeps only valid part of the image.

Non Linearity (ReLU)

ReLU stands for Rectified Linear Unit for a non-linear operation. The output is ƒ(x) = max(0,x).

Why ReLU is important : ReLU’s purpose is to introduce non-linearity in our ConvNet. Since, the real world data would want our ConvNet to learn would be
non-negative linear values.

Figure 7 : ReLU operation

There are other non linear functions such as tanh or sigmoid that can also be used instead of ReLU. Most of the data scientists use ReLU since performance
wise ReLU is better than the other two.

Pooling Layer
Pooling layers section would reduce the number of parameters when the images are too large. Spatial pooling also called subsampling or downsampling
which reduces the dimensionality of each map but retains important information. Spatial pooling can be of different types:

Max Pooling

Average Pooling

Sum Pooling

Max pooling takes the largest element from the rectified feature map. Taking the largest element could also take the average pooling. Sum of all elements
in the feature map call as sum pooling.

Figure 8 : Max Pooling

Fully Connected Layer

The layer we call as FC layer, we flattened our matrix into vector and feed it into a fully connected layer like a neural network.

Figure 9 : After pooling layer, flattened as FC layer

In the above diagram, the feature map matrix will be converted as vector (x1, x2, x3, …). With the fully connected layers, we combined these features
together to create a model. Finally, we have an activation function such as softmax or sigmoid to classify the outputs as cat, dog, car, truck etc.,

Figure 10 : Complete CNN architecture

Summary

Provide input image into convolution layer

Choose parameters, apply filters with strides, padding if requires. Perform convolution on the image and apply ReLU activation to the matrix.

Perform pooling to reduce dimensionality size

Add as many convolutional layers until satisfied

Flatten the output and feed into a fully connected layer (FC Layer)

Output the class using an activation function (Logistic Regression with cost functions) and classifies images.

In the next post, I would like to talk about some popular CNN architectures such as AlexNet, VGGNet, GoogLeNet, and ResNet.
References :

https://www.mathworks.com/discovery/convolutional-neural-network.html

https://adeshpande3.github.io/adeshpande3.github.io/A-Beginner's-Guide-To-Understanding-Convolutional-Neural-Networks/

https://ujjwalkarn.me/2016/08/11/intuitive-explanation-convnets/

https://blog.datawow.io/interns-explain-cnn-8a669d053f8b.

Machine Learning Cnn Convolution Neural Net Image Recognition Neural Networks

Follow

Written by Prabhu Raghav


1.97K followers · 183 following

SuperAgentX - https://www.superagentx.ai/ OpenSource Agentic AGI Framework — Decisionfacts.ai, Deeplore.io

Responses (45)

Gowthambreeze

What are your thoughts?

Saliya Ekanayake
Jun 23, 2018

Really nice explanation. Thanks!

18 Reply

Hamid Haghdoost
Dec 8, 2018

Thank you for your clear and fluent tutorial, I enjoyed that and I learned the base of CNN in less than 10 minutes :)

14 Reply

veena tapaswi
Feb 21, 2019

neat explanation… thanks

6 Reply

See all responses

More from Prabhu Raghav

Open in app

Search
Prabhu Raghav

Master Agentic AI: A Beginner’s Step-by-Step Guide with SuperAgentX — Tutorial Series (Part 1)
Hello Everyone, Welcome to the Agent AI Tutorial Series — Part 1! 🚀

Nov 20, 2024 247 1

In DecisionFacts by Prabhu Raghav

Understanding Mathematics behind floating-point precisions


Introduction

May 11, 2024 57 1


Prabhu Raghav

CNN Architectures — LeNet, AlexNet, VGG, GoogLeNet and ResNet


In my previous blog post, explained about my understanding of Convolution Neural Network (CNN). In this post, I am going to detailing about…

Mar 15, 2018 348 3

In TDS Archive by Prabhu Raghav

Linear Regression Simplified - Ordinary Least Square vs Gradient Descent


What is Linear Regression? Linear regression is a statistical method of finding the relationship between independent and dependent…

May 15, 2018 2.2K 13

See all from Prabhu Raghav


Recommended from Medium

Hugman Sangkeun Jung

Automatic Differentiation and the Computational Graph


Understanding Automatic Differentiation and Computational Graphs in Modern Machine Learning

Apr 18 4

LM Po

Basics of Convolutional Neural Networks (CNNs)


If you’re not a Medium subscriber, click here to read the full article.

Feb 17 26 2
Mohana Roy Chowdhury

Everything you need to know about CNNs Part 5: Batch Normalization


So far in the series, we’ve covered the Convolution Layer, the Pooling layer, the Dense Layer, and the Activation Function. We’ve discussed…

Jan 23 145

In Self Study Notes by Cevher Dogan

What is CNN (Convolutional Neural Networks)?


A Convolutional Neural Network (CNN) is a type of deep learning algorithm specifically designed for processing structured data like images…

Nov 30, 2024 11


Emir Uzun

Common CNN Architectures: LeNet, AlexNet, VGG, and ResNet


We will summarize the logic and functionality of popular CNN architectures. LeNet,AlexNet,VGG, ResNet.

Jan 12 53

Kaouthar EL BAKOURI

ANN vs DNN
ANN and DNN for (Deep Neural Network) (Artificial Neural Network): it’s a very broad term that encompasses any form of Deep Learning model…

Feb 3

See more recommendations

You might also like