Artificial Intelligence and Machine Learning
Multi Layer Neural Network
Week 4 - Lecture
The Perceptron Model.
Week - 4 - Multi Layer Neural Network
2
Perceptron for Real Value Inputs.
3
The activation function
4
Importance of Activation Functions
The purpose of the activation functions is to introduce non linearity to the neural network
What if we wanted to build the neural network to distinguish these two different type of data points?
Importance of Activation Functions
The purpose of the activation functions is to introduce non linearity to the neural network
Activation functions allow us to approximate such complex non linear functions
Some common Activation Functions
Threshold Function
Linear Function
Sigmoid Functions
ReLU Function
The Perceptron :Forward Propagation
Building Neural Network with Perceptrons
Limitations of Perceptron
Neural Network and The Theory of Universal Approximation
For Boolean functions of n inputs, at most 2^n neurons in one hidden layer suffice
e.g. for n = 2 inputs:
2^2 = 4 neurons in one hidden layer
Single Layer Neural Network
As every node in a layer is connected to every node of the previous layer, it is called a Dense (fully connected) Layer
Challenges of one hidden layer network
2^n neurons may work well for Boolean input but does not work the same for real world problems
As we may need millions of neurons in the hidden layer which is computationally inefficient!!!
(eg. Dog vs Cat classification)
Solution: Using deeper neural networks aka Multi Layered Neural Network!!
Deep Neural Networks
Why go deeper?
Deep Neural Network Architecture
How DNN work! (An example)
image from internet, subjected to copyrights!
How DNN work! (An example)
image from internet, subjected to copyrights!
Quantifying Loss (Loss Function)
Predicted
Actual
Empirical Loss (Cost)
Measures the average loss over the entire dataset:
Also known as :
Objective Function /
Cost Function /
Empirical Risk
Choosing the right Cost function
Empirical Risk Minimization
Empirical Risk Minimization
The Cost is the function of network weights w/θ
Our Goal is to minimize it
Empirical Risk Minimization
How?
Remember Gradient Descent?
Empirical Risk Minimization
Gradient Descent Algorithm
Computing Gradient in DNN
Computing Gradient in DNN
X
Apply Chain Rule Here
Computing Gradient in DNN
W₂
Computing Gradient in DNN
W₂
Repeat this for the weights of every layers using gradient from later layers!
Back propagation Algorithm
The training proceeds in two phases:
Forward Pass:
Backward Pass
In this phase, an error signal is produced by comparing the output of the network with a desired response.
The resulting error signal is propagated in backward direction through the network, again layer by layer.
In this second phase, successive adjustments are made to the synaptic weights of the network
Backpropagation Algorithm
32
Backpropagation Algorithm
The total cost E(n) for all the neurons in the output layer is therefore
33
Backpropagation Algorithm
34
Back propagation Algorithm
Backpropagation Algorithm
36
Backpropagation Algorithm
37
Backpropagation Algorithm
38
Backpropagation Algorithm
Case I: Neuron j is output layer neuron
39
where:
Therefore :
Backpropagation Algorithm
Case II: Neuron j is hidden layer neuron
40
Backpropagation Algorithm
Algorithm
compute the net input of unit j with respect to the previous
layer,
compute the output of each unit j
41
Learning
Algorithm
//Weight Update
42
Gradient Descent in Practice
Batch Gradient Descent
Stochastic Gradient Descent
Mini- Batch Gradient Descent
Challenges
Thank You!