SlideShare a Scribd company logo
1 of 30
Convolutional
Neural Network
Introduction
 In the past few decades, Deep Learning has proved to be a very powerful tool because of its
ability to handle large amounts of data. The interest to use hidden layers has surpassed
traditional techniques, especially in pattern recognition. One of the most popular deep neural
networks is Convolutional Neural Networks.
APPLICATIONS
• OCR and image recognition
• Decoding Facial Recognition
• Analyzing Documents
• Grey Areas
• Detecting objects in self-driving cars
• Social media face recognition
• Image analysis in medicine
• Advertising
What exactly is a CNN?
 In deep learning, a convolutional neural network (CNN/ConvNet) is a class of deep neural networks, most
commonly applied to analyze visual imagery. Now when we think of a neural network we think about matrix
multiplications but that is not the case with ConvNet. It uses a special technique called Convolution. Now in
mathematics convolution is a mathematical operation on two functions that produces a third function that
expresses how the shape of one is modified by the other. But we don’t really need to go behind the mathematics part to
understand what a CNN is or how it works.
 Bottom line is that the role of the ConvNet is to reduce the images into a form that is easier to process, without losing features
that are critical for getting a good prediction.
Artificial Neural Network
Introduction
 Convolutional Neural Networks (CNNs) learns multi-level features and
 classifier in a joint fashion and performs much better than traditional
 approaches for various image classification and segmentation problems.
How does it work?
 Before we go to the working of CNN’s let’s cover the basics such as what is an image
and how is it represented. An RGB image is nothing but a matrix of pixel values
having three planes whereas a grayscale image is the same but it has a single plane.
Take a look at this image to understand more.
For simplicity, let’s stick with grayscale images as we
try to understand how CNNs work.
Convolution
• The primary purpose of Convolution in case of a CNN is to extract features from the input image.
Convolution...
 • The size of the output volume is controlled by three parameters that we need to decide
before the convolution step is performed:
 Depth: Depth corresponds to the number of filters we use for the convolution operation.
 Stride: Stride is the number of pixels by which we slide our filter matrix over the input
matrix.
 Zero-padding: Sometimes, it is convenient to pad the input matrix with zeros around the
border, so that we can apply the filter to bordering elements of our input image matrix.
• With zero-padding wide convolution
• Without zero-padding narrow convolution
Non-Linearity (ReLU)
 • Replaces all negative pixel values in the feature map by
zero.
 • The purpose of ReLU is to introduce nonlinearity in CNN,
since most of the real-worlddata would be non-linear.
 • Other non-linear functions such as tanh (-1,1) or sigmoid
(0,1) can also be used instead ofReLU (0,input).
Pooling
 Reduces the dimensionality of each feature map but retains the most important information.
Pooling can be of different types: Max, Average, Sum etc.
 • Together these layers extract the useful features from the images.
 • The output from the convolutional and pooling layers represent high-level features of the input
image.
Overall CNN Architecture
Putting it all together – Training using Backpropagation
 • Step 1: We initialize all filters and parameters / weights with random values.
 • Step 2: The network takes a training image as input, goes through the forward propagation
step (convolution, ReLU and pooling operations along with forward propagation in the Fully
Connected layer) and finds the output probabilities for each class.
 • Let’s say the output probabilities for the boat image above are [0.2, 0.4, 0.1, 0.3].
 • Since weights are randomly assigned for the first training example, output probabilities are
also random.
 • Step 3: Calculate the total error at the output layer (summation over all 4 classes).
 Step 4: Use Backpropagation to calculate the gradients of the error with respect to all weights
in the network and use gradient descent to update all filter values/ weights and parameter
values to minimize the output error.
• The weights are adjusted in proportion to their contribution to the total error.
• When the same image is input again, output probabilities might now be [0.1, 0.1, 0.7, 0.1],
which is closer to the target vector [0, 0, 1, 0].
• This means that the network has learnt to classify this particular image correctly by adjusting its
weights / filters such that the output error is reduced.
• Parameters like number of filters, filter sizes, architecture of the network etc. have all been fixed
before Step 1 and do not change during training process – only the values of the filter matrix and
connection weights get updated.
 • Step 5: Repeat steps 2-4 with all images in the training set
• Parameters like number of filters, filter sizes, architecture of the network etc. have all
been fixed before Step 1 and do not change during training process – only the values of
the filter matrix and connection weights get updated.
 • Step 5: Repeat steps 2-4 with all images in the training set
SEQUENTIAL
 Model - Sequential
 Sequential is the easiest way to build a model in Keras. It allows you to build a model layer by
layer. Each layer has weights that correspond to the layer the follows it.
• We use the ‘add()’ function to add layers to our model.
• ‘Dense’ is the layer type. Dense is a standard layer type that works for most cases. In a dense layer, all
nodes in the previous layer connect to the nodes in the current layer.
 We define nodes in each of our input layers. This number can also be in the hundreds or
thousands. Increasing the number of nodes in each layer increases model capacity. I will go into
further detail about the effects of increasing model capacity shortly.
• ‘Activation’ is the activation function for the layer. An activation function allows models to take into
account nonlinear relationships.
 The first layer needs an input shape. The input shape specifies the number of rows and columns
in the input.
 The last layer is the output layer. It only has one node, two nodes as per requirment. which is for
our prediction.

Compiling Model.
 Compiling the model takes two parameters: optimizer and loss.
• The optimizer controls the learning rate. We will be
using ‘adam’ as our optmizer.
• Adam is generally a good optimizer to use for many cases. The
adam optimizer adjusts the learning rate throughout training.
• The learning rate determines how fast the optimal weights for the
model are calculated. A smaller learning rate may lead to more
accurate weights (up to a certain point), but the time it takes to
compute the weights will be longer.
Train
• we will use the ‘fit()’ function on our model with the following five parameters:
• training data (train_X),
• target data (train_y),
• validation split,
• number of epochs
• The validation split will randomly split the data into use for training and testing.
• During training, we will be able to see the validation loss, If we will set the
validation split at 0.2, which means that 20% of the training data we provide in
the model will be set aside for testing model performance.
• The number of epochs is the number of times the model will cycle through the
data. The more epochs we run, the more the model will improve, up to a certain
point. After that point, the model will stop improving during each epoch. In
addition, the more epochs, the longer the model will take to run. To monitor this,
we will use ‘early stopping’.
• Early stopping will stop the model from training before the number of epochs is
reached if the model stops improving. We will set our early stopping monitor to
3. This means that after 3 epochs in a row in which the model doesn’t improve,
training will stop. Sometimes, the validation loss can stop improving then
improve in the next epoch, but after 3 epochs in which the validation loss doesn’t
improve, it usually won’t improve again.
• to make predictions on new data, we would use the ‘predict()’ function, passing
in our new data.
 As you increase the number of nodes and layers in a model, the model capacity
increases. Increasing model capacity can lead to a more accurate model, up to
a certain point, at which the model will stop improving. Generally, the more
training data you provide, the larger the model should be.
Programming
importing libaries
 We import required libraries
 Importing Numpy , Pandas ,
 Importing Tensorflow As Tf
 From Tensorflow Import Keras
 Reading The Data
• Here we have 785 columns
Importing sequential model and adding fliters and layers
Running epochs
visualization
Evaluate score
• Here we got 98% accuracy
THANK YOU

More Related Content

What's hot

What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
Simplilearn
 

What's hot (20)

Convolutional Neural Network
Convolutional Neural NetworkConvolutional Neural Network
Convolutional Neural Network
 
Convolutional neural network
Convolutional neural networkConvolutional neural network
Convolutional neural network
 
CNN and its applications by ketaki
CNN and its applications by ketakiCNN and its applications by ketaki
CNN and its applications by ketaki
 
Machine Learning - Convolutional Neural Network
Machine Learning - Convolutional Neural NetworkMachine Learning - Convolutional Neural Network
Machine Learning - Convolutional Neural Network
 
Convolutional neural network
Convolutional neural networkConvolutional neural network
Convolutional neural network
 
Cnn
CnnCnn
Cnn
 
CNN Tutorial
CNN TutorialCNN Tutorial
CNN Tutorial
 
Convolutional neural network from VGG to DenseNet
Convolutional neural network from VGG to DenseNetConvolutional neural network from VGG to DenseNet
Convolutional neural network from VGG to DenseNet
 
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
 
Image Classification using deep learning
Image Classification using deep learning Image Classification using deep learning
Image Classification using deep learning
 
CNN Machine learning DeepLearning
CNN Machine learning DeepLearningCNN Machine learning DeepLearning
CNN Machine learning DeepLearning
 
Convolutional Neural Network and Its Applications
Convolutional Neural Network and Its ApplicationsConvolutional Neural Network and Its Applications
Convolutional Neural Network and Its Applications
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer Vision
 
Image classification using CNN
Image classification using CNNImage classification using CNN
Image classification using CNN
 
Cnn
CnnCnn
Cnn
 
Cnn method
Cnn methodCnn method
Cnn method
 
Convolutional Neural Networks (CNN)
Convolutional Neural Networks (CNN)Convolutional Neural Networks (CNN)
Convolutional Neural Networks (CNN)
 
Convolutional Neural Network (CNN) - image recognition
Convolutional Neural Network (CNN)  - image recognitionConvolutional Neural Network (CNN)  - image recognition
Convolutional Neural Network (CNN) - image recognition
 
Deep Learning - Overview of my work II
Deep Learning - Overview of my work IIDeep Learning - Overview of my work II
Deep Learning - Overview of my work II
 
Deep learning
Deep learning Deep learning
Deep learning
 

Similar to cnn ppt.pptx

House Price Estimation as a Function Fitting Problem with using ANN Approach
House Price Estimation as a Function Fitting Problem with using ANN ApproachHouse Price Estimation as a Function Fitting Problem with using ANN Approach
House Price Estimation as a Function Fitting Problem with using ANN Approach
Yusuf Uzun
 

Similar to cnn ppt.pptx (20)

Deep Computer Vision - 1.pptx
Deep Computer Vision - 1.pptxDeep Computer Vision - 1.pptx
Deep Computer Vision - 1.pptx
 
YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...
YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...
YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...
 
ML Module 3 Non Linear Learning.pptx
ML Module 3 Non Linear Learning.pptxML Module 3 Non Linear Learning.pptx
ML Module 3 Non Linear Learning.pptx
 
Facial Emotion Detection on Children's Emotional Face
Facial Emotion Detection on Children's Emotional FaceFacial Emotion Detection on Children's Emotional Face
Facial Emotion Detection on Children's Emotional Face
 
UNIT-4.pptx
UNIT-4.pptxUNIT-4.pptx
UNIT-4.pptx
 
Deep learning-practical
Deep learning-practicalDeep learning-practical
Deep learning-practical
 
UNIT-4.pdf
UNIT-4.pdfUNIT-4.pdf
UNIT-4.pdf
 
UNIT-4.pdf
UNIT-4.pdfUNIT-4.pdf
UNIT-4.pdf
 
cnn.pdf
cnn.pdfcnn.pdf
cnn.pdf
 
Mnist soln
Mnist solnMnist soln
Mnist soln
 
TensorFlow.pptx
TensorFlow.pptxTensorFlow.pptx
TensorFlow.pptx
 
Human Head Counting and Detection using Convnets
Human Head Counting and Detection using ConvnetsHuman Head Counting and Detection using Convnets
Human Head Counting and Detection using Convnets
 
backpropagation in neural networks
backpropagation in neural networksbackpropagation in neural networks
backpropagation in neural networks
 
House Price Estimation as a Function Fitting Problem with using ANN Approach
House Price Estimation as a Function Fitting Problem with using ANN ApproachHouse Price Estimation as a Function Fitting Problem with using ANN Approach
House Price Estimation as a Function Fitting Problem with using ANN Approach
 
Introduction to Convolutional Neural Networks
Introduction to Convolutional Neural NetworksIntroduction to Convolutional Neural Networks
Introduction to Convolutional Neural Networks
 
Deeplearning
Deeplearning Deeplearning
Deeplearning
 
Introduction to Perceptron and Neural Network.pptx
Introduction to Perceptron and Neural Network.pptxIntroduction to Perceptron and Neural Network.pptx
Introduction to Perceptron and Neural Network.pptx
 
EssentialsOfMachineLearning.pdf
EssentialsOfMachineLearning.pdfEssentialsOfMachineLearning.pdf
EssentialsOfMachineLearning.pdf
 
Unit 2 ml.pptx
Unit 2 ml.pptxUnit 2 ml.pptx
Unit 2 ml.pptx
 
Automated Speech Recognition
Automated Speech Recognition Automated Speech Recognition
Automated Speech Recognition
 

Recently uploaded

Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
HyderabadDolls
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
gajnagarg
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
nirzagarg
 
Lake Town / Independent Kolkata Call Girls Phone No 8005736733 Elite Escort S...
Lake Town / Independent Kolkata Call Girls Phone No 8005736733 Elite Escort S...Lake Town / Independent Kolkata Call Girls Phone No 8005736733 Elite Escort S...
Lake Town / Independent Kolkata Call Girls Phone No 8005736733 Elite Escort S...
HyderabadDolls
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
gajnagarg
 
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
HyderabadDolls
 
Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...
nirzagarg
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
nirzagarg
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
nirzagarg
 

Recently uploaded (20)

5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
 
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
 
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
 
Lake Town / Independent Kolkata Call Girls Phone No 8005736733 Elite Escort S...
Lake Town / Independent Kolkata Call Girls Phone No 8005736733 Elite Escort S...Lake Town / Independent Kolkata Call Girls Phone No 8005736733 Elite Escort S...
Lake Town / Independent Kolkata Call Girls Phone No 8005736733 Elite Escort S...
 
Introduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptxIntroduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptx
 
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRanking and Scoring Exercises for Research
Ranking and Scoring Exercises for Research
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - Almora
 
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
 
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
 
Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
 
Vastral Call Girls Book Now 7737669865 Top Class Escort Service Available
Vastral Call Girls Book Now 7737669865 Top Class Escort Service AvailableVastral Call Girls Book Now 7737669865 Top Class Escort Service Available
Vastral Call Girls Book Now 7737669865 Top Class Escort Service Available
 
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With OrangePredicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
 

cnn ppt.pptx

  • 2. Introduction  In the past few decades, Deep Learning has proved to be a very powerful tool because of its ability to handle large amounts of data. The interest to use hidden layers has surpassed traditional techniques, especially in pattern recognition. One of the most popular deep neural networks is Convolutional Neural Networks.
  • 3. APPLICATIONS • OCR and image recognition • Decoding Facial Recognition • Analyzing Documents • Grey Areas • Detecting objects in self-driving cars • Social media face recognition • Image analysis in medicine • Advertising
  • 4. What exactly is a CNN?  In deep learning, a convolutional neural network (CNN/ConvNet) is a class of deep neural networks, most commonly applied to analyze visual imagery. Now when we think of a neural network we think about matrix multiplications but that is not the case with ConvNet. It uses a special technique called Convolution. Now in mathematics convolution is a mathematical operation on two functions that produces a third function that expresses how the shape of one is modified by the other. But we don’t really need to go behind the mathematics part to understand what a CNN is or how it works.  Bottom line is that the role of the ConvNet is to reduce the images into a form that is easier to process, without losing features that are critical for getting a good prediction.
  • 6.
  • 7. Introduction  Convolutional Neural Networks (CNNs) learns multi-level features and  classifier in a joint fashion and performs much better than traditional  approaches for various image classification and segmentation problems.
  • 8. How does it work?  Before we go to the working of CNN’s let’s cover the basics such as what is an image and how is it represented. An RGB image is nothing but a matrix of pixel values having three planes whereas a grayscale image is the same but it has a single plane. Take a look at this image to understand more.
  • 9. For simplicity, let’s stick with grayscale images as we try to understand how CNNs work.
  • 10. Convolution • The primary purpose of Convolution in case of a CNN is to extract features from the input image.
  • 11. Convolution...  • The size of the output volume is controlled by three parameters that we need to decide before the convolution step is performed:  Depth: Depth corresponds to the number of filters we use for the convolution operation.  Stride: Stride is the number of pixels by which we slide our filter matrix over the input matrix.  Zero-padding: Sometimes, it is convenient to pad the input matrix with zeros around the border, so that we can apply the filter to bordering elements of our input image matrix. • With zero-padding wide convolution • Without zero-padding narrow convolution
  • 12. Non-Linearity (ReLU)  • Replaces all negative pixel values in the feature map by zero.  • The purpose of ReLU is to introduce nonlinearity in CNN, since most of the real-worlddata would be non-linear.  • Other non-linear functions such as tanh (-1,1) or sigmoid (0,1) can also be used instead ofReLU (0,input).
  • 13. Pooling  Reduces the dimensionality of each feature map but retains the most important information. Pooling can be of different types: Max, Average, Sum etc.
  • 14.  • Together these layers extract the useful features from the images.  • The output from the convolutional and pooling layers represent high-level features of the input image.
  • 16. Putting it all together – Training using Backpropagation  • Step 1: We initialize all filters and parameters / weights with random values.  • Step 2: The network takes a training image as input, goes through the forward propagation step (convolution, ReLU and pooling operations along with forward propagation in the Fully Connected layer) and finds the output probabilities for each class.  • Let’s say the output probabilities for the boat image above are [0.2, 0.4, 0.1, 0.3].  • Since weights are randomly assigned for the first training example, output probabilities are also random.  • Step 3: Calculate the total error at the output layer (summation over all 4 classes).
  • 17.  Step 4: Use Backpropagation to calculate the gradients of the error with respect to all weights in the network and use gradient descent to update all filter values/ weights and parameter values to minimize the output error. • The weights are adjusted in proportion to their contribution to the total error. • When the same image is input again, output probabilities might now be [0.1, 0.1, 0.7, 0.1], which is closer to the target vector [0, 0, 1, 0]. • This means that the network has learnt to classify this particular image correctly by adjusting its weights / filters such that the output error is reduced. • Parameters like number of filters, filter sizes, architecture of the network etc. have all been fixed before Step 1 and do not change during training process – only the values of the filter matrix and connection weights get updated.  • Step 5: Repeat steps 2-4 with all images in the training set
  • 18. • Parameters like number of filters, filter sizes, architecture of the network etc. have all been fixed before Step 1 and do not change during training process – only the values of the filter matrix and connection weights get updated.  • Step 5: Repeat steps 2-4 with all images in the training set
  • 19. SEQUENTIAL  Model - Sequential  Sequential is the easiest way to build a model in Keras. It allows you to build a model layer by layer. Each layer has weights that correspond to the layer the follows it. • We use the ‘add()’ function to add layers to our model. • ‘Dense’ is the layer type. Dense is a standard layer type that works for most cases. In a dense layer, all nodes in the previous layer connect to the nodes in the current layer.  We define nodes in each of our input layers. This number can also be in the hundreds or thousands. Increasing the number of nodes in each layer increases model capacity. I will go into further detail about the effects of increasing model capacity shortly. • ‘Activation’ is the activation function for the layer. An activation function allows models to take into account nonlinear relationships.  The first layer needs an input shape. The input shape specifies the number of rows and columns in the input.  The last layer is the output layer. It only has one node, two nodes as per requirment. which is for our prediction. 
  • 20. Compiling Model.  Compiling the model takes two parameters: optimizer and loss. • The optimizer controls the learning rate. We will be using ‘adam’ as our optmizer. • Adam is generally a good optimizer to use for many cases. The adam optimizer adjusts the learning rate throughout training. • The learning rate determines how fast the optimal weights for the model are calculated. A smaller learning rate may lead to more accurate weights (up to a certain point), but the time it takes to compute the weights will be longer.
  • 21. Train • we will use the ‘fit()’ function on our model with the following five parameters: • training data (train_X), • target data (train_y), • validation split, • number of epochs • The validation split will randomly split the data into use for training and testing. • During training, we will be able to see the validation loss, If we will set the validation split at 0.2, which means that 20% of the training data we provide in the model will be set aside for testing model performance.
  • 22. • The number of epochs is the number of times the model will cycle through the data. The more epochs we run, the more the model will improve, up to a certain point. After that point, the model will stop improving during each epoch. In addition, the more epochs, the longer the model will take to run. To monitor this, we will use ‘early stopping’. • Early stopping will stop the model from training before the number of epochs is reached if the model stops improving. We will set our early stopping monitor to 3. This means that after 3 epochs in a row in which the model doesn’t improve, training will stop. Sometimes, the validation loss can stop improving then improve in the next epoch, but after 3 epochs in which the validation loss doesn’t improve, it usually won’t improve again. • to make predictions on new data, we would use the ‘predict()’ function, passing in our new data.  As you increase the number of nodes and layers in a model, the model capacity increases. Increasing model capacity can lead to a more accurate model, up to a certain point, at which the model will stop improving. Generally, the more training data you provide, the larger the model should be.
  • 24.  We import required libraries  Importing Numpy , Pandas ,  Importing Tensorflow As Tf  From Tensorflow Import Keras  Reading The Data
  • 25. • Here we have 785 columns
  • 26. Importing sequential model and adding fliters and layers
  • 29. Evaluate score • Here we got 98% accuracy