EPS-DL-Handout3-Build ANN From Scratch Basics
EPS-DL-Handout3-Build ANN From Scratch Basics
SESSION-3
BY
ASHA
Introduction to Neural Networks
• Neural networks are computational models inspired by the
human brain. They consist of interconnected units or nodes
called neurons, organized into layers.
• Neural networks are capable of learning from data and
making predictions or decisions without being explicitly
programmed.
A simple neural network consists of three components :
•Input layer
•Hidden layer
•Output layer
1. In the first step, Input units are passed i.e data is passed with
some weights attached to it to the hidden layer. We can have any
number of hidden layers. In the above image inputs x1,x2,x3,….xn is
passed.
2. Each hidden layer consists of neurons. All the inputs are connected
to each neuron.
3. After passing on the inputs, all the computation is performed in
the hidden layer.
• Computation performed in hidden layers are done in two steps which are as
follows :
• First of all, all the inputs are multiplied by their weights. Weight is the
gradient or coefficient of each variable. It shows the strength of the
particular input. After assigning the weights, a bias variable is added. Bias is
a constant that helps the model to fit in the best way possible.
Z1 = W1*In1 + W2*In2 + W3*In3 + W4*In4 + W5*In5 + b
• W1, W2, W3, W4, W5 are the weights assigned to the inputs In1, In2, In3, In4,
In5, and b is the bias.
• Then in the second step, the activation function is applied to the linear
equation Z1. The activation function is a nonlinear transformation that is
applied to the input before sending it to the next layer of neurons. The
importance of the activation function is to inculcate nonlinearity in the
model.
4. The whole process described in point 3 is performed in each hidden
layer. After passing through every hidden layer, we move to the last
layer i.e our output layer which gives us the final output.
The process explained above is known as forwarding Propagation.
5. After getting the predictions from the output layer, the error is
calculated i.e the difference between the actual and the predicted
output.
If the error is large, then the steps are taken to minimize the error and for
the same purpose, Back Propagation is performed.
Forward Propagation
• The process of computing the output of a neural network. It
involves:
1. Multiplying inputs by weights.
2. Adding biases.
3. Applying the activation function to produce the output.
Loss Function
• A measure of how well the neural network's predictions
match the actual results. Common loss functions include:
• Mean Squared Error (MSE): For regression tasks.
• Cross-Entropy Loss: For classification tasks.
Backpropagation
• The process of updating weights and biases based on the error
of the network's predictions. It involves:
1. Computing the gradient of the loss function with respect to
each weight using the chain rule.
2. Adjusting weights and biases to minimize the loss function.
What is Back Propagation and How it works?
• Back Propagation is the process of updating and finding the
optimal values of weights or coefficients which helps the model
to minimize the error i.e difference between the actual and
predicted values.
• How the weights are updated and new weights are
calculated?
• The weights are updated with the help of optimizers.
Optimizers are the methods/ mathematical formulations to
change the attributes of neural networks i.e weights to
minimizer the error
Back Propagation with Gradient Descent
• Gradient Descent is one of the optimizers which helps in
calculating the new weights. Let’s understand step by step
how Gradient Descent optimizes the cost function.
• In the image below, the curve is our cost function curve and
our aim is the minimize the error such that Jmin i.e global
minima is achieved.
Steps to achieve the global minima: