[go: up one dir, main page]

0% found this document useful (0 votes)
84 views139 pages

Course Slides

The document discusses deep learning concepts including artificial neural networks (ANN), propagation of information in ANNs, neural network architectures, activation functions, gradient descent algorithms, and convolutional neural networks (CNN). ANNs are computational models that mimic the human brain, while deep learning uses deep neural networks to perform machine learning tasks. Frameworks like Python are commonly used to implement ANNs and CNNs.

Uploaded by

Chimaroke Umunna
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)
84 views139 pages

Course Slides

The document discusses deep learning concepts including artificial neural networks (ANN), propagation of information in ANNs, neural network architectures, activation functions, gradient descent algorithms, and convolutional neural networks (CNN). ANNs are computational models that mimic the human brain, while deep learning uses deep neural networks to perform machine learning tasks. Frameworks like Python are commonly used to implement ANNs and CNNs.

Uploaded by

Chimaroke Umunna
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/ 139

DEEP LEARNING

WITH PYTHON
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures


What is deep learning?

Activation Functions Why is Deep Learning Important?

Gradient Descent Algorithm Software and frameworks

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


What is Deep Learning

What is Deep Learning?


What is Deep Learning
AI: The computer
performs tasks without Programming: Data+ Rules =
explicitly programming Answers
them.
ML: Data + Answers = Rules

What is Deep Learning?

DL: Performing
Machine learning tasks
using deep neural
network(DNN)
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures


What is deep learning?

Activation Functions Why is Deep Learning Important?

Gradient Descent Algorithm Software and frameworks

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Why is Deep Learning Important?

What is Deep Learning?


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures


What is deep learning?

Activation Functions Why is Deep Learning Important?

Gradient Descent Algorithm Software and frameworks

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Software and Frameworks

What is Deep Learning?


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures


Introduction

Activation Functions Anatomy and function of


neurons
An introduction to the
Gradient Descent Algorithm neural network
Architecture of a neural
Summary Overview of Neural Networks network

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Introduction
An artificial neuron network is a
computational model that mimics
the way nerve cells work in the
human brain.
There are more complicated and
high-end models in the DL
approach. However, ANN is a vital
element in all the models in DL.
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures


Introduction

Activation Functions Anatomy and function of


neurons
An introduction to the
Gradient Descent Algorithm neural network
Architecture of a neural
Summary Overview of Neural Networks network

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Anatomy and function of neurons
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures


Introduction

Activation Functions Anatomy and function of


neurons
An introduction to the
Gradient Descent Algorithm neural network
Architecture of a neural
Summary Overview of Neural Networks network

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


An introduction to the neural network (1/2)
An introduction to the neural network (2/2)
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures


Introduction

Activation Functions Anatomy and function of


neurons
An introduction to the
Gradient Descent Algorithm neural network
Architecture of a neural
Summary Overview of Neural Networks network

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Architecture of a neural network
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures Feed-forward and Back


Propagation Networks
Backpropagation In Neural
Activation Functions
Networks
Minimizing the cost function
Gradient Descent Algorithm using backpropagation

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures Feed-forward and Back


Propagation Networks
Backpropagation In Neural
Activation Functions
Networks
Minimizing the cost function
Gradient Descent Algorithm using backpropagation

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Back Propagation
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures Feed-forward and Back


Propagation Networks
Backpropagation In Neural
Activation Functions
Networks
Minimizing the cost function
Gradient Descent Algorithm using backpropagation

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Single layer perceptron


Propagation of information in ANNs (SLP) model

Radial Basis Network (RBN)


Neural Network Architectures
Multi-layer perceptron (MLP)
Neural Network
Activation Functions
Recurrent neural network (RNN)

Long Short-Term Memory


Gradient Descent Algorithm (LSTM) networks

Hopfield neural network


Summary Overview of Neural Networks
Boltzmann Machine Neural
Network
Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


NN Architecture Types
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Single layer perceptron


Propagation of information in ANNs (SLP) model

Radial Basis Network (RBN)


Neural Network Architectures
Multi-layer perceptron
(MLP) Neural Network
Activation Functions
Recurrent neural network (RNN)

Long Short-Term Memory


Gradient Descent Algorithm (LSTM) networks

Hopfield neural network


Summary Overview of Neural Networks
Boltzmann Machine Neural
Network
Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


NN Architecture Types
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Single layer perceptron


Propagation of information in ANNs (SLP) model

Radial Basis Network (RBN)


Neural Network Architectures
Multi-layer perceptron (MLP)
Neural Network
Activation Functions
Recurrent neural network (RNN)

Long Short-Term Memory


Gradient Descent Algorithm (LSTM) networks

Hopfield neural network


Summary Overview of Neural Networks
Boltzmann Machine Neural
Network
Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


NN Architecture Types
Introduction to Deep Learning

Artificial Neural Networks (ANN)

What is the Activation Function?


Propagation of information in ANNs

Important Terminologies
Neural Network Architectures
The sigmoid function

Activation Functions
Hyperbolic tangent function

Gradient Descent Algorithm Softmax function

Rectified Linear Unit (ReLU) function


Summary Overview of Neural Networks

Leaky Rectified Linear Unit function


Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


What is the Activation Function? – Superpower for ANN (1/2)

So what actually Activation Function (AF) do? AF is a function that is added into an ANN to
help the network learn complex patterns in the data.
What is the Activation Function? – Superpower for ANN (2/2)
Introduction to Deep Learning

Artificial Neural Networks (ANN)

What is the Activation Function?


Propagation of information in ANNs

Important Terminologies
Neural Network Architectures
The sigmoid function

Activation Functions
Hyperbolic tangent function

Gradient Descent Algorithm Softmax function

Rectified Linear Unit (ReLU) function


Summary Overview of Neural Networks

Leaky Rectified Linear Unit function


Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Important Terminologies

1. Differential function: Change in Y-axis w.r.t change in X-axis (slope!)

2. Monotonic function: A function which is increasing on its entire


domain or decreasing on its entire domain.
Introduction to Deep Learning

Artificial Neural Networks (ANN)

What is the Activation Function?


Propagation of information in ANNs

Important Terminologies
Neural Network Architectures
The sigmoid function

Activation Functions
Hyperbolic tangent function

Gradient Descent Algorithm Softmax function

Rectified Linear Unit (ReLU) function


Summary Overview of Neural Networks

Leaky Rectified Linear Unit function


Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Non-Linear Activation Functions (1/5)
Introduction to Deep Learning

Artificial Neural Networks (ANN)

What is the Activation Function?


Propagation of information in ANNs

Important Terminologies
Neural Network Architectures
The sigmoid function

Activation Functions
Hyperbolic tangent function

Gradient Descent Algorithm Softmax function

Rectified Linear Unit (ReLU) function


Summary Overview of Neural Networks

Leaky Rectified Linear Unit function


Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Non-Linear Activation Functions (2/5)
Introduction to Deep Learning

Artificial Neural Networks (ANN)

What is the Activation Function?


Propagation of information in ANNs

Important Terminologies
Neural Network Architectures
The sigmoid function

Activation Functions
Hyperbolic tangent function

Gradient Descent Algorithm Softmax function

Rectified Linear Unit (ReLU) function


Summary Overview of Neural Networks

Leaky Rectified Linear Unit function


Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Non-Linear Activation Functions (3/5)
Introduction to Deep Learning

Artificial Neural Networks (ANN)

What is the Activation Function?


Propagation of information in ANNs

Important Terminologies
Neural Network Architectures
The sigmoid function

Activation Functions
Hyperbolic tangent function

Gradient Descent Algorithm Softmax function

Rectified Linear Unit (ReLU) function


Summary Overview of Neural Networks

Leaky Rectified Linear Unit function


Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Non-Linear Activation Functions (4/5)
Introduction to Deep Learning

Artificial Neural Networks (ANN)

What is the Activation Function?


Propagation of information in ANNs

Important Terminologies
Neural Network Architectures
The sigmoid function

Activation Functions
Hyperbolic tangent function

Gradient Descent Algorithm Softmax function

Rectified Linear Unit (ReLU) function


Summary Overview of Neural Networks

Leaky Rectified Linear Unit function


Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Non-Linear Activation Functions (5/5)
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

What is Gradient Decent?


Neural Network Architectures
What is Stochastic Gradient
Decent?
Activation Functions
Gradient Decent vs
Stochastic Gradient Decent
Gradient Descent Algorithm

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Gradient Decent
Gradient: measures how much the output of a function changes if you change the inputs a little bit. In
mathematics it is similar to slope.

b: next position
a: current position
ϒ(gamma) : waiting factor Convex function
Δf(a) : direction

Gradient Descent = Descending into Minimum of COST function


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

What is Gradient Decent?


Neural Network Architectures
What is Stochastic Gradient
Decent?
Activation Functions
Gradient Decent vs
Stochastic Gradient Decent
Gradient Descent Algorithm

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Stochastic Decent
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

What is Gradient Decent?


Neural Network Architectures
What is Stochastic Gradient
Decent?
Activation Functions
Gradient Decent vs
Stochastic Gradient Decent
Gradient Descent Algorithm

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Stochastic Decent (2/2)
For more clarification between GD and SGD, see the below picture

* Mini Batch Gradient Descent = Gradient Descent + Stochastic Gradient Descent


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures How artificial neural


networks work?
Activation Functions
Advantages of Neural
Networks
Disadvantages of Neural
Gradient Descent Algorithm Networks
Applications of Neural
Summary Overview of Neural Networks Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


How network works? – Overall Summary! (1/4)

• It is consisted of a number of simple but


highly interconnected elements or
nodes, called ‘neurons’. Those neurons
are organized in layers which process
information using dynamic state
responses to external inputs.

• The First layer is the input layer. The


Last layer is the output layer by default.
How network works? – Overall Summary! (2/4)

• Assume that we need to calculate the price


of the house and we don’t have a hidden
layer. So, the price will be simply the
summation of the product of inputs and
their weight respectively. This is an
approach of Machine learning model.

• So, what makes DL approach something


better than the Machine Learning model is
the addition of a hidden layer, it gives some
flexibility and power, to increase accuracy.
How network works? – Overall Summary! (3/4)

• Let us consider estimating the cost of the house for the same example
with ANN. All inputs neurons are connected to all the neurons in the
hidden layer, which means it won’t have the same weightage from the
input layer, which means depending on the priorities the weightage
values changes. Each neuron in the hidden layer has some priorities
and weightage for application-related like how our brain works.

• If we keep on increasing the hidden layers for some importance or


weightage or for solving complex calculations, the accuracy gets
increased, it’s like fine-tuning the network to get the optimal output.
How network works? – Overall Summary! (4/4)
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures How artificial neural


networks work?
Activation Functions
Advantages of Neural
Networks
Disadvantages of Neural
Gradient Descent Algorithm Networks
Applications of Neural
Summary Overview of Neural Networks Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Advantages of ANNs

1. Ability to work with incomplete knowledge

2. Fault tolerance

3. Parallel processing capability


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures How artificial neural


networks work?
Activation Functions
Advantages of Neural
Networks
Disadvantages of Neural
Gradient Descent Algorithm Networks
Applications of Neural
Summary Overview of Neural Networks Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Disadvantages of ANNs

1. Hardware dependence

2. Determination of proper network structure


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs

Neural Network Architectures How artificial neural


networks work?
Activation Functions
Advantages of Neural
Networks
Disadvantages of Neural
Gradient Descent Algorithm Networks
Applications of Neural
Summary Overview of Neural Networks Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Applications

1. Handwritten Recognition

2. Image compression

3. Stock exchange prediction


Quiz Time

1.What is back propagation


a) It is another name given to the curvy function in perceptron
b) It is the transmission of error back through the network to
adjust the input
c) It is the transmission of error back through the network to
allow weights to be adjusted so that the network can learn
d) Node of the mentioned
Quiz Time

1.What is back propagation


a) It is another name given to the curvy function in perceptron
b) It is the transmission of error back through the network to
adjust the input
c) It is the transmission of error back through the network to
allow weights to be adjusted so that the network can learn
d) Node of the mentioned
Introduction to Deep Learning
Introduction
Artificial Neural Networks (ANN)
Exploring the dataset

Propagation of information in ANNs


Problem Statement

Neural Network Architectures Data Pre-processing

Loading the dataset


Activation Functions
Splitting the dataset into
independent and dependent
Gradient Descent Algorithm variables
Label encoding
using scikit-learn
Summary Overview of Neural Networks One-hot encoding using
scikit-learn
Implementation of ANN in Python Training and Test Sets:
Splitting Data

Convolutional Neural Networks (CNN) Feature scaling

Implementation of CNN in Python


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Building the Artificial


Propagation of information in ANNs Neural Network
Adding the input layer
and the first hidden layer
Neural Network Architectures
Adding the next
hidden layer
Activation Functions
Adding the output layer

Gradient Descent Algorithm Compiling the artificial


neural network
Fitting the ANN model to
Summary Overview of Neural Networks the training set
Predicting the
Implementation of ANN in Python test set results

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


ANN Implementation in Python

For implementation, I am going to


use Churn Modelling Dataset. You can
download the dataset from Kaggle.

Artificial Neural Network can be used


for both classification and regression.
And here we are going to use ANN for
classification.
Introduction to Deep Learning
Introduction
Artificial Neural Networks (ANN)
Exploring the dataset

Propagation of information in ANNs


Problem Statement

Neural Network Architectures Data Pre-processing

Loading the dataset


Activation Functions
Splitting the dataset into
independent and dependent
Gradient Descent Algorithm variables
Label encoding
using scikit-learn
Summary Overview of Neural Networks One-hot encoding using
scikit-learn
Implementation of ANN in Python Training and Test Sets:
Splitting Data

Convolutional Neural Networks (CNN) Feature scaling

Implementation of CNN in Python


ANN Implementation in python
This dataset has following features-
Introduction to Deep Learning
Introduction
Artificial Neural Networks (ANN)
Exploring the dataset

Propagation of information in ANNs


Problem Statement

Neural Network Architectures Data Pre-processing

Loading the dataset


Activation Functions
Splitting the dataset into
independent and dependent
Gradient Descent Algorithm variables
Label encoding
using scikit-learn
Summary Overview of Neural Networks One-hot encoding using
scikit-learn
Implementation of ANN in Python Training and Test Sets:
Splitting Data

Convolutional Neural Networks (CNN) Feature scaling

Implementation of CNN in Python


ANN Implementation in python

PROBLEM
STATEMENT
Introduction to Deep Learning
Introduction
Artificial Neural Networks (ANN)
Exploring the dataset

Propagation of information in ANNs


Problem Statement

Neural Network Architectures Data Pre-processing

Loading the dataset


Activation Functions
Splitting the dataset into
independent and dependent
Gradient Descent Algorithm variables
Label encoding
using scikit-learn
Summary Overview of Neural Networks One-hot encoding using
scikit-learn
Implementation of ANN in Python Training and Test Sets:
Splitting Data

Convolutional Neural Networks (CNN) Feature scaling

Implementation of CNN in Python


Data Preprocessing

In data preprocessing the first step is-


Import the Libraries-
Introduction to Deep Learning
Introduction
Artificial Neural Networks (ANN)
Exploring the dataset

Propagation of information in ANNs


Problem Statement

Neural Network Architectures Data Pre-processing

Loading the dataset


Activation Functions
Splitting the dataset into
independent and dependent
Gradient Descent Algorithm variables
Label encoding
using scikit-learn
Summary Overview of Neural Networks One-hot encoding using
scikit-learn
Implementation of ANN in Python Training and Test Sets:
Splitting Data

Convolutional Neural Networks (CNN) Feature scaling

Implementation of CNN in Python


Data Preprocessing

Load the dataset-

So, when you load


the dataset after
running this line of
code, you will get
your data
something like
this-
Introduction to Deep Learning
Introduction
Artificial Neural Networks (ANN)
Exploring the dataset

Propagation of information in ANNs


Problem Statement

Neural Network Architectures Data Pre-processing

Loading the dataset


Activation Functions
Splitting the dataset into
independent and dependent
Gradient Descent Algorithm variables
Label encoding
using scikit-learn
Summary Overview of Neural Networks One-hot encoding using
scikit-learn
Implementation of ANN in Python Training and Test Sets:
Splitting Data

Convolutional Neural Networks (CNN) Feature scaling

Implementation of CNN in Python


Data Preprocessing

Split Dataset into X and Y-


Introduction to Deep Learning
Introduction
Artificial Neural Networks (ANN)
Exploring the dataset

Propagation of information in ANNs


Problem Statement

Neural Network Architectures Data Pre-processing

Loading the dataset


Activation Functions
Splitting the dataset into
independent and dependent
Gradient Descent Algorithm variables
Label encoding
using scikit-learn
Summary Overview of Neural Networks One-hot encoding using
scikit-learn
Implementation of ANN in Python Training and Test Sets:
Splitting Data

Convolutional Neural Networks (CNN) Feature scaling

Implementation of CNN in Python


Data Preprocessing
Independent Variable (X)-
Data Preprocessing
Dependent Variable (Y)-
Introduction to Deep Learning
Introduction
Artificial Neural Networks (ANN)
Exploring the dataset

Propagation of information in ANNs


Problem Statement

Neural Network Architectures Data Pre-processing

Loading the dataset


Activation Functions
Splitting the dataset into
independent and dependent
Gradient Descent Algorithm variables
Label encoding
using scikit-learn
Summary Overview of Neural Networks One-hot encoding using
scikit-learn
Implementation of ANN in Python Training and Test Sets:
Splitting Data

Convolutional Neural Networks (CNN) Feature scaling

Implementation of CNN in Python


Data Preprocessing

Encode Categorical Data-

So first let’s perform label encoding for gender variable-


Data Preprocessing
Data Preprocessing

next is to perform one hot encoding for geography variable-


Data Preprocessing
Introduction to Deep Learning
Introduction
Artificial Neural Networks (ANN)
Exploring the dataset

Propagation of information in ANNs


Problem Statement

Neural Network Architectures Data Pre-processing

Loading the dataset


Activation Functions
Splitting the dataset into
independent and dependent
Gradient Descent Algorithm variables
Label encoding
using scikit-learn
Summary Overview of Neural Networks One-hot encoding using
scikit-learn
Implementation of ANN in Python Training and Test Sets:
Splitting Data

Convolutional Neural Networks (CNN) Feature scaling

Implementation of CNN in Python


Data Preprocessing

Split the X and Y Dataset into Training set and Test set-
Introduction to Deep Learning
Introduction
Artificial Neural Networks (ANN)
Exploring the dataset

Propagation of information in ANNs


Problem Statement

Neural Network Architectures Data Pre-processing

Loading the dataset


Activation Functions
Splitting the dataset into
independent and dependent
Gradient Descent Algorithm variables
Label encoding
using scikit-learn
Summary Overview of Neural Networks One-hot encoding using
scikit-learn
Implementation of ANN in Python Training and Test Sets:
Splitting Data

Convolutional Neural Networks (CNN) Feature scaling

Implementation of CNN in Python


Data Preprocessing

Perform Feature Scaling-


Data Preprocessing
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Building the Artificial


Propagation of information in ANNs Neural Network
Adding the input layer
and the first hidden layer
Neural Network Architectures
Adding the next
hidden layer
Activation Functions
Adding the output layer

Gradient Descent Algorithm Compiling the artificial


neural network
Fitting the ANN model to
Summary Overview of Neural Networks the training set
Predicting the
Implementation of ANN in Python test set results

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Building Artificial Neural Network

The first step is-


Import the Keras libraries and packages-

Initialize the Artificial Neural Network-


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Building the Artificial


Propagation of information in ANNs Neural Network
Adding the input layer and
the first hidden layer
Neural Network Architectures
Adding the next
hidden layer
Activation Functions
Adding the output layer

Gradient Descent Algorithm Compiling the artificial


neural network
Fitting the ANN model to
Summary Overview of Neural Networks the training set
Predicting the
Implementation of ANN in Python test set results

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Building Artificial Neural Network

Add the input layer and the first hidden layer-


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Building the Artificial


Propagation of information in ANNs Neural Network
Adding the input layer
and the first hidden layer
Neural Network Architectures
Adding the next
hidden layer
Activation Functions
Adding the output layer

Gradient Descent Algorithm Compiling the artificial


neural network
Fitting the ANN model to
Summary Overview of Neural Networks the training set
Predicting the
Implementation of ANN in Python test set results

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Building Artificial Neural Network

Add the second hidden layer-


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Building the Artificial


Propagation of information in ANNs Neural Network
Adding the input layer
and the first hidden layer
Neural Network Architectures
Adding the next
hidden layer
Activation Functions
Adding the output layer

Gradient Descent Algorithm Compiling the artificial


neural network
Fitting the ANN model to
Summary Overview of Neural Networks the training set
Predicting the
Implementation of ANN in Python test set results

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Building Artificial Neural Network

Add the output layer-


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Building the Artificial


Propagation of information in ANNs Neural Network
Adding the input layer
and the first hidden layer
Neural Network Architectures
Adding the next
hidden layer
Activation Functions
Adding the output layer

Gradient Descent Algorithm Compiling the artificial


neural network
Fitting the ANN model to
Summary Overview of Neural Networks the training set
Predicting the
Implementation of ANN in Python test set results

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Train the ANN
The training part requires two steps- Compile the ANN, and Fit
the ANN to the Training set. So let’s start with the first step-

Compile the ANN-


Introduction to Deep Learning

Artificial Neural Networks (ANN)

Building the Artificial


Propagation of information in ANNs Neural Network
Adding the input layer
and the first hidden layer
Neural Network Architectures
Adding the next
hidden layer
Activation Functions
Adding the output layer

Gradient Descent Algorithm Compiling the artificial


neural network
Fitting the ANN model to
Summary Overview of Neural Networks the training set
Predicting the
Implementation of ANN in Python test set results

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Train the ANN

The next step is-

Fit the ANN to the Training set-


Train the ANN
In the first few epochs the accuracy scores are as follow-

Which is around 80%, but after running all 100 epoch, the
accuracy increase, and we get the final accuracy-

That is 85.44%. Quite good. Now we are done with the


training part. The last but not least part is Predicting the test
set results-
Train the ANN

The next step is-

Prediction-
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Building the Artificial


Propagation of information in ANNs Neural Network
Adding the input layer
and the first hidden layer
Neural Network Architectures
Adding the next
hidden layer
Activation Functions
Adding the output layer

Gradient Descent Algorithm Compiling the artificial


neural network
Fitting the ANN model to
Summary Overview of Neural Networks the training set
Predicting the
Implementation of ANN in Python test set results

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Predict the Test Set Results
So, after running this code, you will get y_pred something like this-
Make the confusion Matrix

And we got 85.75% accuracy-.


Quiz Time

The number of nodes in the input layer is 10


and the hidden layer is 5. The maximum
number of connections from the input layer to
the hidden layer are
a) 50
b) Less than 50
c) More than 50
d) It is an arbitrary value
Quiz Time

The number of nodes in the input layer is 10


and the hidden layer is 5. The maximum
number of connections from the input layer to
the hidden layer are
a) 50
b) Less than 50
c) More than 50
d) It is an arbitrary value
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs Introduction

Components of convolutional
Neural Network Architectures neural networks
Convolution Layer
Activation Functions
Pooling Layer
Gradient Descent Algorithm
Fully connected Layer

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


CNN-Introduction
What exactly is a CNN

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.
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs Introduction

Components of convolutional
Neural Network Architectures neural networks
Convolution Layer
Activation Functions
Pooling Layer
Gradient Descent Algorithm
Fully connected Layer

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Components of CNN
The CNN model works in two steps: feature extraction and Classification

Feature Extraction is a phase where various filters and layers are applied to
the images to extract the information and features out of it and once it’s
done it is passed on to the next phase i.e Classification where they are
classified based on the target variable of the problem.

A typical CNN model looks like this:


• Input layer
• Convolution layer + Activation function
• Pooling layer
• Fully Connected Layer
Components of CNN

Source: researchgate.net
Input Layer
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs Introduction

Components of convolutional
Neural Network Architectures neural networks
Convolution Layer
Activation Functions
Pooling Layer
Gradient Descent Algorithm
Fully connected Layer

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Convolution Layer (1/4)
Convolution Layer (2/4)
The result of applying the filter to the image is that we get a Feature
Map of 4*4
Convolution Layer (3/4)
Convolution Layer (4/4)
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs Introduction

Components of convolutional
Neural Network Architectures neural networks
Convolution Layer
Activation Functions
Pooling Layer
Gradient Descent Algorithm
Fully connected Layer

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Pooling Layer
The pooling layer is applied after the Convolutional layer.
It is used to reduce the dimensions of the feature maps. Thus, it reduces
the number of parameters to learn. it preserves the important
information or features of the input image.
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs Introduction

Components of convolutional
Neural Network Architectures neural networks
Convolution Layer
Activation Functions
Pooling Layer
Gradient Descent Algorithm
Fully connected Layer

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation of CNN in Python


Fully Connected Layer
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs Dataset

Importing libraries
Neural Network Architectures

Building the CNN


Activation Functions model
Accuracy of the model
Gradient Descent Algorithm

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation
Implementation of
of CNN
CNNininPython
Python
We are going to use MNIST
Handwritten Digit data which
contains the images of
handwritten digits.
Background of CNNs
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs Dataset

Importing libraries
Neural Network Architectures

Building the CNN


Activation Functions model
Accuracy of the model
Gradient Descent Algorithm

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation
Implementation of
of CNN
CNNininPython
Python
Implementation (1/5)
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs Dataset

Importing libraries
Neural Network Architectures

Building the CNN


Activation Functions model
Accuracy of the model
Gradient Descent Algorithm

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation
Implementation of
of CNN
CNNininPython
Python
Implementation (2/5)
Implementation (3/5)
Introduction to Deep Learning

Artificial Neural Networks (ANN)

Propagation of information in ANNs Dataset

Importing libraries
Neural Network Architectures

Building the CNN


Activation Functions model
Accuracy of the model
Gradient Descent Algorithm

Summary Overview of Neural Networks

Implementation of ANN in Python

Convolutional Neural Networks (CNN)

Implementation
Implementation of
of CNN
CNNininPython
Python
Implementation (4/5)
Output-
Implementation (5/5)
Quiz Time

When pooling layer is added in a convolutional


neural network, translation in-variance is
preserved. True or False?
a) True
b) False
Quiz Time

When pooling layer is added in a convolutional


neural network, translation in-variance is
preserved. True or False?
a) True
b) False
THANK YOU

You might also like