0% found this document useful (0 votes)
16 views31 pages

Understanding Convolutional Neural Networks

This document provides an overview of Convolutional Neural Networks (CNNs), detailing their architecture, functionality, and applications in image classification. It outlines the learning objectives, working principles, and the process of building a CNN model for tasks such as handwritten digit recognition using the MNIST dataset. Additionally, it includes self-assessment questions and references for further reading on the topic.

Uploaded by

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

Understanding Convolutional Neural Networks

This document provides an overview of Convolutional Neural Networks (CNNs), detailing their architecture, functionality, and applications in image classification. It outlines the learning objectives, working principles, and the process of building a CNN model for tasks such as handwritten digit recognition using the MNIST dataset. Additionally, it includes self-assessment questions and references for further reading on the topic.

Uploaded by

hope98754
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

CNN-CONVOLUTIONAL NEURAL

NETWORKS
Course: Nature Inspired Soft Computing

Module - 2 CO - 2
AIM OF THE SESSION

To familiarize students with the concepts of CNN ,


To make students apply CNN on a real world problem

INSTRUCTIONAL OBJECTIVES

This unit is designed to:


1. Demonstrate the CNN and its Applications
2. Describe the nature and features CNN
3. Demonstrate the Architecture of CNN

LEARNING OUTCOMES

At the end of this unit, you should be able to:


1. Describe the CNN Architecture
2. Describe the functioning of the Layers of CNN
3. Understand the Application's of CNN.

2
INTRODUCTION TO CNN AND DL

• Convolutional neural networks (CNN/ConvNet) are a type of deep neural


networks used in deep learning.
• Most applied to analyze visual imagery.
• It uses a special technique called Convolution.
• Convolution is a mathematical procedure that, when applied to two functions,
yields a third function that describes how the shape of one function is altered
by the other.
• ConvNet's purpose is to convert images into a form that is simpler to process,
without losing features that are essential for making accurate predictions.

3
BASIC ARCHITECTURE OF CNN

• A convolutional tool that determines and recognizes the numerous image


features for analysis as part of the Feature Extraction process.
• Many combinations of convolutional or pooling layers form the network for
feature extraction.
• A fully connected layer that uses the output of the convolution process to
predict the image's class based on the features extracted in earlier stages.
• The resultant CNN model of feature extraction tries to reduce the number of
features in a dataset.
• It generates new features that summarize the existing features into a set of
original features.
• In line with the CNN architecture diagram,
4 there are numerous CNN layers.
BASIC ARCHITECTURE OF CNN…

• A number of layers of artificial neurons constitute convolutional neural networks.


• Artificial neurons are mathematical functions that calculate the weighted sum of
multiple inputs and output an activation value, imitating their biological counterparts
in an impoverished way.
• When an image is input into a ConvNet, each layer generates multiple activation
functions that are transmitted to the subsequent layer.
• Typically, the first layer extracts fundamental features such as horizontal or diagonal
edges.
• This output is forwarded to the subsequent layer, which detects more complex
features such as corners and combination edges.
• As we progress deeper into the network, it can identify increasingly complex
characteristics, such as objects, personalities, etc.

5
6
BASIC ARCHITECTURE OF CNN…

7
WORKING OF CNN

• Before talking about CNN's operation, let's address the fundamentals,


such as what an image is and how it is represented.
• A RGB image is nothing more than a matrix of pixel values with three
planes, whereas a grayscale image has only one plane. Look at this
image to gain further insight.

8
WORKING OF CONVOLUTIONAL LAYER(GRAY
SCALE IMAGE)

9
WORKING OF CONVOLUTIONAL LAYER
(RGB IMAGE)

10
WORKING OF CONVOLUTIONAL LAYER
(RGB IMAGE)
• If we have an input of size W x W x D and Dout number of kernels with
a spatial size of F with stride S and amount of padding P, then the size
of output volume can be determined by the following formula:

11
CALCULATION OF OUTPUT DIMENSIONS FOR
CONVOLUTIONAL LAYER

12
WORKING OF POOLING LAYER

• Likewise, to the Convolutional Layer, the Pooling Layer's function is


responsible for reducing the Convolved Feature's spatial dimension.
• By reducing the dimensions, the required computational capacity to
process the data will be decreased.
• Two forms of pooling exist: Average pooling and maximum pooling.

13
WORKING OF POOLING LAYER…

• In Max Pooling, the kernel determines the highest value of a pixel from
a section of the image.
• Max Pooling is a Noise Suppressor as well. It eliminates all noisy
activations and executes de-noising and dimension reduction
concurrently.
• Average Pooling, on the other hand, returns the mean of all values from
the portion of the image covered by the kernel.
• Average Pooling merely executes dimension reduction as a means of
reducing noise. Max Pooling therefore performs significantly better than
Average Pooling.

14
WORKING OF POOLING LAYER…

15
WORKING OF POOLING LAYER…

16
IMAGE CLASSIFICATION USING
CONVOLUTIONAL NEURAL NETWORK
• Data scientists are particularly interested in computer vision, and CNNs have
broken the mould to become the most advanced computer vision method.
• CNNs are without a doubt the most well-known of the several neural network
types (others include recurrent neural networks (RNN), long short-term
memory (LSTM), artificial neural networks (ANN), etc.).
• In the world of image data, these convolutional neural network models are
widely used.
• On computer vision tasks like picture categorization, object identification,
image recognition, etc., they perform remarkably well.

17
IMAGE CLASSIFICATION USING
CONVOLUTIONAL NEURAL NETWORK…
• As a result, they have been extensively utilized in artificial intelligence
modelling, particularly for developing picture classifiers.
• This Session will explain the idea of picture categorization using CNNs
and demonstrate how they operate on different datasets.
• The MNSIT, CIFAR-10, and ImageNet datasets will be utilised to
demonstrate to us how to construct image classification CNNs in
Python.
• We shall study the operation of CNNs in the context of image
categorization.

18
CLASSIFYING HANDWRITTEN DIGITS ON THE
MNIST DATASET USING CNNS
• Yann Le Cun and colleagues created the MNIST (Modified National
Institute of Standards and Technology), a well-known dataset used in
computer vision.
• It is made up of images of handwritten digits (0–9) that are divided into
training sets of 50,000 and test sets of 10,000.
• Each image is 28 x 28 pixels in size.

19
IMPORT THE LIBRARIES AND LOAD THE
DATASET
• All the modules that we will require for training our model will first be
imported.
• There are already certain datasets in the Keras library, and MNIST is
one of them.
• Therefore, importing the dataset and using it are both simple
processes.
• The training data, its labels, as well as the testing data and its labels,
are returned to us by the mnist.load_data() method.

20
IMPORT THE LIBRARIES AND LOAD THE
DATASET…

21
PREPROCESS THE DATA

• We must execute some operations and process the data in order to


prepare it for our neural network because the image data cannot be
supplied straight into the model.
• The training data's dimension is (60000,28,28). We reconstruct the
matrix to take the form (60000,28,28,1) because the CNN model will
need one extra dimension.

22
PREPROCESS THE DATA…

23
CREATE THE MODEL

• Our CNN model will now be developed in a Python data science project.
• Convolutional and pooling layers are the most common components of
CNN models.
• Because it performs better for data that are represented as grid
structures, CNN is a good choice for challenges involving image
categorization.
• When training, the dropout layer minimises offer fitting of the model by
deactivating part of the neurons.
• The Adadelta optimizer will then be used to compile the model.

24
CREATE THE MODEL…

25
TRAIN AND EVALUATING THE MODEL

• The [Link]() function of Keras will start the training of the model. It takes the
training data, validation data, epochs, and batch size
• It takes some time to train the model.
• After training, we save the weights and model definition in the ‘mnist.h5’ file.
• Our dataset, which contains 10,000 images, will be utilized to evaluate how well our
model performs.
• Since the testing data was not used to train the model, it is new data for our model.
• Since the MNIST dataset is nicely balanced, we can get an accuracy of about 99%.

26
TRAIN AND EVALUATING THE MODEL…

27
SUMMARY

• Convolutional neural networks (CNNs) are a type of deep learning algorithm


that are specifically designed for image recognition and tasks that involve the
processing of pixel data.
• CNNs are inspired by the way the human visual cortex works. It is organized
into a series of layers, each of which performs a different function. The first
layer of the visual cortex receives input from the retina, and the subsequent
layers perform increasingly complex processing of the visual information.
• CNNs are able to learn to identify patterns in images by using a series of
convolution and pooling layers. Convolution layers apply a filter to an image,
which helps to identify specific features in the image.
• CNNs have been used for a variety of imaging applications, including image
classification, object detection, medical image analysis, and image
segmentation.
28
SELF ASSESSMENT QUESTIONS

1. Which of the following is well suited for perceptual tasks?


a. MLP
b. CNN
c. RBM
d. All of the above

2. Which of the following is NOT a layer in a CNN?


a. Convolution layer
b. Pooling layer
c. Fully connected layer
d. Recurrent layer

29
SELF ASSESSMENT QUESTIONS…

3. What is the main advantage of CNN over MLP?


a. CNN is able to learn spatial hierarchies of features.
b. CNN is able to learn temporal hierarchies of features.
c. CNN is able to learn both spatial and temporal hierarchies of features.
d. None of the above.

4. What is the stride in a convolution layer?


a. The number of times the filter is applied to the input image.
b. The number of pixels that are skipped between each application of the filter.
c. The size of the filter.
d. The number of channels in the input image.

30
REFERENCE BOOKS AND WEBLINKS

• Deep Learning From Scratch: Building with Python from First Principles by Seth
Weidman published by O`Reilley
• Hands-on machine learning with Scikit-learn Keras and TensorFlow by Aurelion
Geron published by O` Reilley
• [Link]
8c4939
• [Link]
ssification-5997bfd0ede4
• [Link]
• [Link]
ognition/
• [Link]
tional-neural-networks-a-step-by-step-guide/
31

You might also like