1 of 151

Deep Learning

2 of 151

3 of 151

Relation between AI, ML and DL

4 of 151

5 of 151

sites.google.com/view/rajkumars1987

5

24-Jul-26

rajkumars@vit.ac.in

Why Deep Learning

6 of 151

sites.google.com/view/rajkumars1987

6

24-Jul-26

rajkumars@vit.ac.in

Why Deep Learning

7 of 151

Deep Learning

  • Deep learning imitates the way our brain works i.e. it learns from experiences. It uses the concepts of neural networks to solve complex problems.
  • Informally, a Neural Network with several layers of neurons between input and output layers

8 of 151

Deep Learning Applications Across Industries

  • Self Driving Cars
  • News Aggregation and Fraud News Detection
  • Natural Language Processing
  • Virtual Assistants
  • Entertainment
  • Visual Recognition
  • Fraud Detection
  • Healthcare
  • Personalisations
  • Detecting Developmental Delay in Children
  • Colourisation of Black and White images
  • Adding sounds to silent movies
  • Automatic Machine Translation
  • Automatic Handwriting Generation
  • Automatic Game Playing
  • Language Translations
  • Pixel Restoration
  • Photo Descriptions
  • Demographic and Election Predictions
  • Deep Dreaming

9 of 151

Deep Learning Architectures

10 of 151

Deep Learning Architectures (2)

Architecture

Applications

RNN

Speech recognition, handwriting recognition

LSTM/GRU networks

Natural language text compression, handwriting recognition, speech recognition, gesture recognition, image captioning

CNN

Image recognition, video analysis, natural language processing

DBN

Image recognition, information retrieval, natural language understanding, failure prediction

DSN

Information retrieval, continuous speech recognition

11 of 151

Biological inspiration and neural networks

12 of 151

Example Scenario

13 of 151

Summary

In your brain:

  • Each sensory input activates a neuron.
    • A sound activates an auditory neuron.
    • Footprints activate a visual detection neuron.
    • Memory of past tiger encounter activates memory neurons.
  • Your brain sums all the signals.
    • If the total threat score is high → You RUN!
    • If the score is low → You stay calm.

Neural Network Perspective

Each input = one neuron (input node)

The three circles represent input neurons.

Each arrow = connection with a weight

  • Weight shows importance of the input.
  • In the forest example:
    • “Saw a tiger last week” may have a higher weight
    • “Hear a sound” may have medium weight
    • “Footprints” may have high weight

Summation (Σ) = neuron combining all signals

The Σ symbol represents a neuron body that:

  1. Receives signals
  2. Multiplies each by its weight
  3. Sums them
  4. Applies an activation function (decision rule)

14 of 151

Biological Neurons

15 of 151

16 of 151

Relationship b/w Biological vs Artificial NN

Biological Neuron

Artificial Neuron (ANN)

Dendrites

Inputs

Synaptic strength

Weights

Cell body (soma)

Weighted sum + bias

Axon

Output

Firing (action potential)

Activation function

17 of 151

Neuron Model

18 of 151

Evolution of Neural Networks

Stage / Period

Key Idea

Diagram (Layer-wise Representation)

Limitations

1940s–1950s Early Model

McCulloch–Pitts neuron

(x₁, x₂) → [ ⚪ ] → y

No learning, only fixed logic

1958 Perceptron

Frank Rosenblatt single-layer model

Input Layer → [ ⚪ ] → Output

Cannot solve non-linear problems (XOR)

1969–1980s AI Winter

Marvin Minsky showed limits

Input → [ ⚪ ] → Output (no hidden layer)

Very limited capability

1980s–1990s MLP + Backprop

Multi-layer learning

Input → [ ⚪ ⚪ ] → [ ⚪ ] → Output

Slow training, local minima

1990s–2000s CNN & RNN

Specialized architectures

CNN: Input → [▣▣] → [⚪] → Output RNN: x₁ → [⚪] → x₂ → [⚪] → …

Needs more data, vanishing gradient

2010s Deep Learning

Deep multi-layer networks

Input → [ ⚪ ⚪ ⚪ ⚪ ] → [ ⚪ ⚪ ] → Output

High computation, needs big data

2017–Present Transformers

Attention mechanism

Input → [ ⚪ ⚪ ] ⇄ [ ⚪ ⚪ ] → Output

Very high memory & compute cost

19 of 151

Basic models of ANN

  • The models of ANN has three basic entities are

- the models synaptic interconnections

- the training or learning rules for updating the connection weights

- their activation functions

20 of 151

Connections

Type of Connection

Description

Diagram (Simple)

Key Feature

1. Fully Connected

Every neuron connects to all neurons in next layer

Input → [ ⚪⚪⚪ ] → [ ⚪⚪ ]

Maximum information flow

2. Partially Connected

Only some neurons are connected

x₁ → ⚪ x₂ → ⚪

Reduces complexity

3. Feedforward Connection

Data flows in one direction only

Input → Hidden → Output

No loops

4. Feedback (Recurrent)

Output fed back into network

x → ⚪ ↺

Has memory

5. Lateral Connection

Neurons connect within same layer

⚪ ↔ ⚪ ↔ ⚪

Used for competition

6. Self-Connection

Neuron connects to itself

⚪ ↺

Stores past value

Notes : ANN connections include fully connected, partially connected, feedforward,

feedback (recurrent), lateral, and self-connections, each defining how neurons

are linked and how information flows.

21 of 151

Learning

Type

Description

Example

Limitation

Supervised Learning

Learns using labeled data

Classification, Regression

Needs labeled dataset

Unsupervised Learning

Finds patterns in unlabeled data

Clustering

Less accurate

Reinforcement Learning

Learns using reward/penalty

Games, Robotics

Slow and complex

Note : “Learning in ANN is the process of updating weights and bias based on error to improve the network’s performance.”

22 of 151

Activation functions

  • Activation functions are an integral building block of neural networks that enable them to learn complex patterns in data.
  • They transform the input signal of a node in a neural network into an output signal that is then passed on to the next layer.
  • Without activation functions, neural networks would be restricted to modeling only linear relationships between inputs and outputs.
  • Activation functions introduce non-linearities, allowing neural networks to learn highly complex mappings between inputs and outputs.
  • Activation functions enable neural networks to learn these non-linear relationships by introducing non-linear behaviors through activation functions.
  • This greatly increases the flexibility and power of neural networks to model complex and nuanced data.

23 of 151

Activation function

Function

Formula

Range

Use

Limitation

Step Function

0 or 1

Simple classification

Not differentiable

Sigmoid

(0,1)

Binary classification

Vanishing gradient

Tanh

(-1,1)

Better than sigmoid

Still vanishing gradient

ReLU

[0,∞)

Most widely used

Dead neuron problem

Leaky ReLU

(-∞,∞)

Fixes ReLU issue

Slight complexity

Softmax

(0,1)

Multi-class classification

Computationally expensive

24 of 151

Activation function

Function

Used in Hidden Layer

Used in Output Layer

Common Use

Step Function

❌ No

Rarely

Early perceptrons, not used in modern deep learning

Sigmoid

❌ Rarely

✅ Yes

Binary classification (output probability 0–1)

Tanh

✅ Yes

Sometimes

Hidden layers (less common today)

ReLU

✅ Yes (Most Common)

❌ No

Hidden layers in deep neural networks

Leaky ReLU

✅ Yes

❌ No

Hidden layers; avoids the "dying ReLU" problem

Softmax

❌ No

✅ Yes

Multi-class classification (e.g., digits 0–9)

25 of 151

Activation function

Activation Function

Advantages

Disadvantages

Step Function

• Simple to implement.

• Works for basic binary decisions.

• Not differentiable.• Cannot be trained using backpropagation.• Not used in modern deep learning.

Sigmoid

• Output ranges from 0 to 1 (good for probabilities).• Ideal for binary classification output.

• Suffers from the vanishing gradient problem.• Slow convergence.• Output is not zero-centered.

Tanh

• Output ranges from -1 to 1.• Zero-centered, often learns faster than sigmoid.

• Also suffers from the vanishing gradient problem.• Less commonly used than ReLU in deep networks.

ReLU (Rectified Linear Unit)

• Simple and fast to compute.• Reduces the vanishing gradient problem.• Most widely used activation for hidden layers.

• Can suffer from the dying ReLU problem (neurons may stop learning if outputs remain negative).

Leaky ReLU

• Solves the dying ReLU problem by allowing a small negative output.• Faster learning than sigmoid and tanh.

• The negative slope is a hyperparameter that must be chosen.• Slightly more computationally expensive than ReLU.

Softmax

• Produces probabilities that sum to 1.• Best choice for multi-class classification.

• Used only in the output layer.• Can become overconfident in its predictions if the model is poorly calibrated.

26 of 151

Why Do We Need Activation Functions?

  • An activation function determines whether a neuron should be activated and what output it should produce. It introduces nonlinearity into a neural network, enabling it to learn complex patterns.
  • Without activation functions, a neural network would behave like a simple linear model, regardless of how many hidden layers it has.

27 of 151

Why Are Activation Functions Important?

1. Introduce Nonlinearity

  • Real-world problems are usually nonlinear.

Examples:

  • Face recognition
  • Speech recognition
  • Handwriting recognition
  • Stock price prediction

Activation functions allow neural networks to learn these complex relationships.

28 of 151

Why Are Activation Functions Important?

2. Enable Learning of Complex Patterns

Each hidden layer extracts more advanced features.

Image -> Edges -> Shapes -> Face

Without activation functions, the network cannot learn these hierarchical features.

29 of 151

Why Are Activation Functions Important?

3. Prevent the Network from Behaving Like Linear Regression

Suppose a network has several hidden layers:

Input → Hidden Layer → Hidden Layer → Output

If every neuron uses only a linear function:

y=Wx+b then the entire network is mathematically equivalent to one linear transformation:

Input ─────────────► Output

This means adding more layers provides no extra learning power.

30 of 151

Why Are Activation Functions Important?

4. Control the Output Range

Different activation functions produce outputs in different ranges.

Activation Function

Output Range

Sigmoid

0 to 1

Tanh

-1 to 1

ReLU

0 to ∞

Softmax

Probabilities that sum to 1

These ranges make activation functions suitable for different tasks.

31 of 151

Why Are Activation Functions Important?

5. Improve Training Efficiency

Modern activation functions such as ReLU help reduce the vanishing gradient problem, allowing deep networks to train faster and more effectively.

32 of 151

Activation function

33 of 151

Without vs With Activation Function

  • Without Activation Function
  • With Activation Function

34 of 151

Example without and with activation in network

  • Note : “An activation function is a mathematical function applied to the neuron’s output to introduce non-linearity and determine the final output.”

35 of 151

Loss Functions

  • A loss function measures how far a neural network's prediction is from the actual (true) value. It tells the model how much error it has made during training.
  • Low loss → Better prediction
  • High loss → Poor prediction
  • The goal of training is to minimize the loss by updating the network's weights.

36 of 151

Loss Functions

Loss Function

Problem Type

Common Output Activation

Advantages

Disadvantages

MSE

Regression

Linear

Simple, penalizes large errors

Sensitive to outliers

MAE

Regression

Linear

Robust to outliers

Penalizes large errors less

Binary Cross-Entropy

Binary Classification

Sigmoid

Accurate probability learning

Sensitive to wrong confident predictions

Categorical Cross-Entropy

Multi-Class Classification

Softmax

Best for multiple classes

Requires probability outputs

Hinge Loss

Binary Classification (SVM)

None/Linear

Good class separation

Rarely used in neural networks

37 of 151

Function Approximation in Neural Networks

  • Function approximation is one of the fundamental ideas behind neural networks. It means that a neural network learns a mathematical function that maps inputs to outputs.
  • Mathematically,
  • y=f(x)
  • where:
  • x = input
  • f = function learned by the neural network
  • y = predicted output
  • The goal of training is to make the learned function f(x)f(x)f(x) as close as possible to the true relationship between inputs and outputs.

38 of 151

Sample of Activation usage in Neural Network

39 of 151

Classification and Clustering Problems

Feature

Classification

Clustering

Learning Type

Supervised Learning

Unsupervised Learning

Data Labels

Labeled data

Unlabeled data

Goal

Predict a known class

Discover hidden groups

Output

Predefined categories

Naturally formed clusters

Classification and clustering are two important machine learning tasks. Although both involve grouping data, they differ in how they learn from the data.

40 of 151

Classification and Clustering: Examples and Common Algorithms

Learning Task

Real-World Examples

Common Algorithms

Classification (Supervised Learning)

• Email Spam Detection�• Disease Diagnosis�• Handwritten Digit Recognition�• Face Recognition�• Sentiment Analysis�• Fraud Detection�• Loan Approval Prediction

• Logistic Regression�• Decision Tree�• Random Forest�• Support Vector Machine (SVM)�• K-Nearest Neighbors (KNN)�• Naïve Bayes�• Neural Networks

Clustering (Unsupervised Learning)

• Customer Segmentation�• Market Basket Analysis�• Document Grouping�• News Article Clustering�• Image Segmentation�• Social Network Analysis�• Gene Expression Analysis

• K-Means Clustering�• Hierarchical Clustering�• DBSCAN (Density-Based Spatial Clustering)�• Gaussian Mixture Models (GMM)�• Mean Shift Clustering�• OPTICS�• Spectral Clustering

41 of 151

Simple Illustration

  • Classification

  • Clustering

42 of 151

Deep Networks Basics

  • A Deep Neural Network (DNN) is a neural network with multiple hidden layers between the input and output layers. These additional hidden layers enable the network to learn increasingly complex patterns from data.
  • Simple Neural Network:

-1 hidden layer

  • Deep Neural Network:

-2 or more hidden layers

43 of 151

Shallow Neural Networks

  • A Shallow Neural Network (SNN) is a neural network that has only one hidden layer between the input layer and the output layer.
  • Although it contains only one hidden layer, it can still learn nonlinear relationships using activation functions such as ReLU, Sigmoid, or Tanh.

44 of 151

Deep Network vs Shallow Network

Feature

Shallow Network

Deep Network

Hidden Layers

One

Two or more

Feature Learning

Limited

Hierarchical and automatic

Complexity

Low

High

Accuracy

Moderate

High (with enough data)

Training Time

Short

Longer

Applications

Simple tasks

Complex tasks (vision, NLP, speech)

45 of 151

Common Activation Functions

Layer

Activation Function

Hidden Layers

ReLU, Leaky ReLU, Tanh

Output Layer (Binary Classification)

Sigmoid

Output Layer (Multi-class Classification)

Softmax

Output Layer (Regression)

Linear

46 of 151

Summary

Artificial Intelligence isn't magic—it's mathematics, algorithms, and practice. Keep learning, keep experimenting, and you'll be amazed at what you can create.

Thank you

"A journey of a thousand miles begins with a single step."Lao Tzu

Today, you've taken your first step into the world of AI.

47 of 151

  • Activation & Loss functions

48 of 151

49 of 151

Loss Vs Error

Loss

Error

A continuous value that measures how bad a prediction is.

Indicates whether the prediction is correct or incorrect (or by how much it differs).

Used to train the neural network.

Used to evaluate model performance.

Must be differentiable for backpropagation.

May or may not be differentiable.

Examples: Cross-Entropy, Mean Squared Error (MSE).

Examples: Misclassification rate, Accuracy, Absolute error.

50 of 151

Activation functions

  • Activation functions are an integral building block of neural networks that enable them to learn complex patterns in data.
  • They transform the input signal of a node in a neural network into an output signal that is then passed on to the next layer.
  • Without activation functions, neural networks would be restricted to modeling only linear relationships between inputs and outputs.
  • Activation functions introduce non-linearities, allowing neural networks to learn highly complex mappings between inputs and outputs.
  • Activation functions enable neural networks to learn these non-linear relationships by introducing non-linear behaviors through activation functions.
  • This greatly increases the flexibility and power of neural networks to model complex and nuanced data.

51 of 151

52 of 151

Types of Activation Functions

53 of 151

Plot Sigmoid Function in the range(-5, 5)

x

Sigmoid(x)

-5

-4

-3

-2

-1

0

1

2

3

4

5

54 of 151

Plot Sigmoid Function in the range(-5, 5)

x

Sigmoid(x)

-5

0.006

-4

0.017

-3

0.047

-2

0.119

-1

0.268

0

0.500

1

0.731

2

0.880

3

0.952

4

0.982

5

0.993

Why is this a problem?

Because the outputs are always positive:

  • The gradients flowing backward tend to have the same sign.
  • This can cause zig-zag updates during gradient descent, making optimization slower.
  • It also introduces a bias in the activations.

55 of 151

Plot Tanh Function

x

Tanh(x)

-5

-4

-3

-2

-1

0

1

2

3

4

5

56 of 151

Plot Tanh Function

x

Tanh(x)

-5

-0.99

-4

-0.99

-3

-0.99

-2

-0.96

-1

-0.76

0

0

1

0.76

2

0.96

3

0.99

4

0.99

5

0.99

57 of 151

Plot ReLu Function

x

ReLU(x)

-5

-4

-3

-2

-1

0

1

2

3

4

5

58 of 151

Plot ReLu Function

x

ReLU(x)

-5

0.000000

-4

0.000000

-3

0.000000

-2

0.000000

-1

0.000000

0

0.000000

1

1.000000

2

2.000000

3

3.000000

4

4.000000

5

5.000000

59 of 151

ReLu Function

  • Problems:

  • 1. Dying ReLU Problem
  • 2. Not Zero-Centered
  • 3. Unbounded Positive Outputs
  • 4. Sensitive to Learning Rate

Activation

Formula

Advantage

ReLU

max(0,x))

Simple and fast

Leaky ReLU

max(0.01x,x))

Small gradient for negative inputs, reducing dead neurons

Parametric ReLU (PReLU)

max(\alpha x,x))

Learns the negative slope during training

ELU

Smooth negative values

Better gradient flow for negative inputs

GELU

Used in Transformers (e.g., BERT, GPT)

Smooth activation with strong empirical performance

Why is ReLU still preferred?

Despite these issues, ReLU has significant advantages:

  • ✅ Very fast to compute
  • ✅ Helps avoid the vanishing gradient problem for positive inputs
  • ✅ Leads to sparse activations (many outputs become zero)
  • ✅ Trains deep networks much faster than sigmoid or tanh

Variants that fix the dying ReLU problem

60 of 151

Softmax Function

  • Softmax is used in the output layer for multi-class classification problems.
  • Each neuron corresponds to one class and produces a probability score.
  • It converts raw neuron outputs (logits) into values between 0 and 1.
  • The sum of all output probabilities is always equal to 1.
  • Outputs can be directly interpreted as class confidence scores.
  • The class with the highest probability is selected as the final prediction.
  • Softmax introduces competition among output neurons.
  • Increasing the probability of one class automatically reduces others.

61 of 151

Softmax Function

62 of 151

63 of 151

Softmax function

64 of 151

Error Functions

  • A lower error indicates that the model's predictions are closer to the actual values, leading to better performance.

  • Minimizing the error function is crucial because it directly impacts the model's ability to generalize to new, unseen data.

  • Error functions, or loss functions, measure the difference between the predicted output of a model and the actual target values.

  • They provide a quantitative measure of how well the model is performing.

  • The goal during training is to minimize this error, thereby improving the model's accuracy.

65 of 151

Loss Function vs Cost Function

  • The loss function calculates the error for a single data point. (sample), the cost function calculates the loss for the entire dataset.

  • The cost of a neural network is nothing but the sum of losses on individual training samples.

  • The terms loss and cost are often used interchangeably,

66 of 151

Loss Functions

  • Mean Absolute Error (MAE)
  • Mean Squared Error (MSE)
  • Root Mean Squared Error (RMSE)
  • Categorical Cross Entropy
  • Binary Cross Entropy
  • Sparse Categorical Cross Entropy

67 of 151

Mean Absolute Error (MAE)

  • Calculates the average of the absolute differences between predicted and actual values, providing a more robust measure against outliers

68 of 151

Example: MAE

x

Target(t)

Y=wx

Error=|y-t|

1.2

2.65

3.4

7.50

2.8

6.17

7.3

16.09

Here

X is input,

W is weight, [Assume w=0.8] Y is the network’s output and t is the target value of the training data.

69 of 151

Example: MAE

MAE=(1.69+4.78+3.93+10.25)/4

=20.65/4=5.1625

x

t

y

Error

1.2

2.65

0.96

1.69

3.4

7.50

2.72

4.78

2.8

6.17

2.24

3.93

7.3

16.09

5.84

10.3

70 of 151

Mean Square Error

  • Calculates the average of the squares of the errors, giving a higher penalty to larger errors.

71 of 151

Example: MSE

x

t

Y=wx

Error=(y-t)^2

1.2

2.65

3.4

7.50

2.8

6.17

7.3

16.09

Here

X is input,

W is weight, [Assume w=0.8] Y is the network’s output and t is the target value of the training data.

72 of 151

Example: MSE

x

t

y

(y-t)

(Y-t)^2

1.2

2.65

0.96

-1.69

2.86

3.4

7.5

2.72

-4.78

22.8

2.8

6.17

2.24

-3.93

15.4

7.3

16.1

5.84

-10.25

105

  • MSE=(2.86+22.8+15.4+105)/4=36.6

73 of 151

Root Mean Square Error (RMSE)

  • It measures the average magnitude of the errors between the predicted values and the actual values.

74 of 151

Example: MSE

x

t

Y=wx

Error=(y-t)^2

1.2

2.65

3.4

7.50

2.8

6.17

7.3

16.09

Here

X is input,

W is weight, [Assume w=0.8] Y is the network’s output and t is the target value of the training data.

75 of 151

Example: RMSE

x

t

y

(y-t)

(Y-t)^2

1.2

2.65

0.96

-1.69

2.86

3.4

7.5

2.72

-4.78

22.8

2.8

6.17

2.24

-3.93

15.4

7.3

16.1

5.84

-10.25

105

  • MSE=(2.86+22.8+15.4+105)/4=36.6
  • RMSE=√36.6=6.05

76 of 151

Binary Cross Entropy Loss

True Label

(yi)

1

Predicted

Label (𝑦𝑖 )

0.99

Example: Assume n=1[Only one sample]

77 of 151

78 of 151

79 of 151

Categorical Cross Entropy Loss

  • Categorical Encoding is used

80 of 151

Sparse Categorical Crossentropy

  • The categorical cross-entropy becomes very memory in-efficient when we have a large number of classes, say 1000.
  • This means we have a large array of all zeros and a single 1. In such cases, we use the sparse categorical cross entropy loss function.
  • This loss function works on label-encoded data instead of one-hot encoded data, which makes computation very fast when working with a large number of classes.

81 of 151

Sparse Categorical Crossentropy

82 of 151

Perceptron neural networks

83 of 151

What is Perceptron?

A Perceptron is one of the simplest and most fundamental unit of artificial neural networks, introduced by Frank Rosenblatt in 1957.

  • The perceptron is a liner model for supervised learning.
  • It is used for linear classification.

The perceptron consists of following component's

  • Inputs
  • Weights
  • Bias
  • Weighted Sum
  • Activation Function
  • Output

84 of 151

Architecture

85 of 151

Perceptron Learning Algorithm

  • Step 1 : Initialize all weights and Bias
  • Initialize weights w1, w2, ..., wn ≈ small random values
  • Initialize bias b ≈ 0
  • Choose learning rate η (0 < η ≤ 1)

  • Step 2 : Input representation
  • Input vector: x = (x1, x2, ..., xn)
  • True label: y ∈ {0,1} or {-1,1}
  • Step 3 : Compute response of the network (Weighted Sum)
  • z = w·x + b
  • z = Σi(wi xi) + b

86 of 151

Perceptron Learning Algorithm

  • Step 4 : Activation Function

  • Step 5 : Compute Error
  • Error = y - ŷ
  • Step 6 : Update Weights and bias
  • wi(new) = wi(old) + η(y - ŷ)xi
  • b(new) = b(old) + η(y - ŷ)
  • Step 7 : Repeat
  • Repeat steps 2–6 for all training samples
  • Continue for multiple epochs until:
  • Error = 0 (perfect classification), OR
  • Maximum iterations reached

87 of 151

Example

  • Implement the AND function using Perceptron network for binary inputs and targets with 3 epochs

x₁

x₂

y (Actual)

0

0

0

0

1

0

1

0

0

1

1

1

88 of 151

  • Step 1 : Initialize all weights and Bias
  • w1​=0,w2​=0,b=0,η=1
  • Step 2 : Input representation

  • Step 3 -6 : Formula

x₁

x₂

y (Actual)

0

0

0

0

1

0

1

0

0

1

1

1

89 of 151

Epoch 1

x₁

x₂

y

w₁ (before)

w₂ (before)

b (before)

z

ŷ

Error

w₁ (after)

w₂ (after)

b (after)

0

0

0

0

0

0

0

1

-1

0

0

-1

0

1

0

0

0

-1

-1

0

0

0

0

-1

1

0

0

0

0

-1

-1

0

0

0

0

-1

1

1

1

0

0

-1

-1

0

+1

1

1

0

Epoch 2

x₁

x₂

y

w₁ (before)

w₂ (before)

b (before)

z

ŷ

Error

w₁ (after)

w₂ (after)

b (after)

0

0

0

1

1

0

0

1

-1

1

1

-1

0

1

0

1

1

-1

0

1

-1

1

0

-2

1

0

0

1

0

-2

-1

0

0

1

0

-2

1

1

1

1

0

-2

-1

0

+1

2

1

-1

90 of 151

Epoch 3

x₁

x₂

y

w₁ (before)

w₂ (before)

b (before)

z

ŷ

Error

w₁ (after)

w₂ (after)

b (after)

0

0

0

2

1

-1

-1

0

0

2

1

-1

0

1

0

2

1

-1

0

1

-1

2

0

-2

1

0

0

2

0

-2

0

1

-1

1

0

-3

1

1

1

1

0

-3

-2

0

+1

2

1

-2

91 of 151

Limitation of Perceptron

  • Cannot Solve Non-Linear Problems

👉 Biggest limitation

- Perceptron can only draw a straight line (linear boundary)

- Cannot handle problems like XOR

Example:

- AND → ✔ works

- XOR → ❌ fails

  • Only Binary Classification

-Output is only:0 or 1

-Cannot directly handle: Multi-class problems, Continuous outputs

92 of 151

Limitation of Perceptron

  • Requires Linearly Separable Data

- Works only if data can be separated by a single line

- If data overlaps: Perceptron will never converge

  • No Probability Output

-Gives only hard decision (0 or 1)

-Does NOT provide: Confidence, Probability

  • Sensitive to Learning Rate

- If learning rate is:

  • Too large → unstable
  • Too small → slow learning

93 of 151

Limitation of Perceptron

  • Limited Learning Capacity

- Single-layer perceptron:

  • Cannot learn complex patterns
  • No hidden layers
  • No Probability Output
  • Bias Toward Linear Decision Boundary

- Always assumes:

- Real-world data is often non-linear

94 of 151

Thank you

95 of 151

Gradient Descent

96 of 151

Definition

  • Gradient Descent is an optimization algorithm used to minimize the loss (error) of a neural network by updating its weights and biases.
  • Its goal is to find the best values of the weights that produce the lowest possible error

97 of 151

Why Do We Need Gradient Descent?

  • When a neural network makes a prediction, it may not be correct.
  • Example:

Actual House Price: $300,000

Predicted Price: $250,000

Error = $50,000

  • Gradient Descent updates the weights so that future predictions become more accurate.

98 of 151

How Gradient Descent Works

  • Step 1: Initialize Weights : Randomly assign initial weights
  • Step 2: Forward Propagation : Use the current weights to make a prediction
  • Step 3: Calculate Loss : Compare the predicted output with the actual output
  • Step 4: Compute Gradient

Calculate how much each weight contributed to the error.

Large gradient → Large weight update

Small gradient → Small weight update

  • Step 5: Update Weights : The weight update formula is:

  • Step 6: Repeat : Repeat the process until the loss becomes very small.

99 of 151

Mountain Analogy

  • Imagine standing on top of a mountain in heavy fog.
  • Your goal is to reach the lowest point (valley).
  • The mountain = Loss Function
  • The height = Error
  • The slope (gradient) tells you which direction is downhill.
  • You take small steps downhill until you reach the bottom.

  • Gradient Descent works in the same way—it follows the slope to reach the minimum error.

100 of 151

How to Compute the Gradient in Neural Networks

  • The gradient tells us how much the loss changes when a weight changes. It is the partial derivative of the loss function with respect to a weight.
  • Mathematically,

101 of 151

How to Compute the Gradient in Neural Networks

  • Step 1 : Loss Function

  • Step 2: Prediction Equation

102 of 151

How to Compute the Gradient in Neural Networks

  • Step 3: Differentiate Step by Step

103 of 151

How to Compute the Gradient in Neural Networks

  • Step 3: Differentiate Step by Step

104 of 151

How to Compute the Gradient in Neural Networks

  • Step 4: Apply the Chain Rule

105 of 151

How to Compute the Gradient in Neural Networks

106 of 151

Types of Gradient Descent

Type

Description

Advantage

Disadvantage

Batch Gradient Descent

Uses the entire dataset to update weights

Stable and accurate

Slow for large datasets

Stochastic Gradient Descent (SGD)

Updates weights after each training example

Fast and suitable for large datasets

Noisy updates

Mini-Batch Gradient Descent

Uses a small batch of samples (e.g., 32 or 64)

Faster and more stable than SGD

Batch size must be chosen

107 of 151

Learning Rate (η)

  • The learning rate (η) is a hyperparameter that controls how much the weights are updated during each iteration of Gradient Descent.
  • The learning rate determines the size of each step during weight updates.
  • Small Learning Rate

Minimum

Slow learning

More Stable

Takes longer to converge

  • Large Learning Rate

Maximum

Faster updates

May miss the minimum

Can become unstable

108 of 151

Learning Rate (η)

  • Good Learning Rate

Minimum

Faster convergence

Stable learning

  • Example

109 of 151

Why Can't We Just Update the Weight by the Gradient?

  • Suppose: Weight (w) = 5
  • Gradient (∂L/∂w) = 20
  • If we update the weight without using a learning rate:

wnew = wold − Gradient = 5 − 20 = −15

  • The weight changes from 5 to −15, which is a very large jump.
  • Problems:

-The update is too large.

- The model may overshoot (miss) the minimum loss.

  • Training can become unstable or even fail to converge.

Therefore, we introduce a Learning Rate (η) to control the size of the update.

  • Example with Learning Rate
  • Suppose: Weight (w) = 5
  • Gradient (∂L/∂w) = 20
  • Learning Rate (η) = 0.1
  • Gradient Descent Formula:

wnew = wold − η(∂L/∂w)

  • Substitute the values:

wnew = 5 − (0.1 × 20) = 5 − 2 = 3

The weight changes smoothly from 5 to 3 instead of making a large jump to −15.

Conclusion:

• Without a learning rate → Very large updates → May overshoot the minimum.

• With a learning rate → Controlled updates → Stable and efficient learning.

110 of 151

Multi-Layer Perceptron (MLP)

111 of 151

What is MLP?

  • A Multi-Layer Perceptron (MLP) is an advanced neural network made of multiple layers of perceptrons.
  • It overcomes the limitation of single perceptron (can solve non-linear problems like XOR)

112 of 151

Structure of MLP

Layers:

  • Input Layer
    • Takes input features
  • Hidden Layer(s)
    • Performs computations
    • Can be one or more layers
  • Output Layer
    • Produces final result

113 of 151

MLP Properties

  • Every layer except the input layer includes a bias neuron.
  • It is fully connected to the next layer
  • No connections within a layer
  • No direct connections between input and output layers
  • When an ANN has two or more hidden layers, it is called a deep neural network (DNN)

Note : 1. Number of output units need not equal number of input units

2. Number of hidden units per layer can be more or less than input or output units

114 of 151

114

What do each of the layers do?

1st layer draws linear boundaries

2nd layer combines the boundaries

3rd layer can generate arbitrarily complex boundaries

Note : 1. Perceptron : Can draw only single line

2. MLP : Combines multiple lines → forms curves, polygons, complex regions

115 of 151

MLP with Back propagation

  • Rumelhart  introducing the back propagation training algorithm for MLP.
  • Back propagation has two phases: Forward Propagation and Backward Propagation
  • Forward Propagation:
  • Input → Hidden layer
  • Apply weights + bias
  • Apply activation
  • Pass to next layer
  • Final output generated

116 of 151

MLP with Back propagation

  • Backward Propagation:

Core learning algorithm of MLP

Step

  1. Compute loss
  2. Calculate error
  3. Propagate error backward
  4. Update weights using gradient descent

117 of 151

MLP with Back propagation Algorithm

  • Step 1 : Initialize weights and Biases randomly
  • Initialize weights w11, w12, ..., wij ≈ small random values
  • Initialize biases b1,b2,…,bj ≈ small random values
  • Choose learning rate η (0 < η ≤ 1)
  • Step 2 : Forward Propagation Phase
  • For each layer:
  • Hidden layer
  • Step 2.1 : Each input unit x = (x1, x2, ..., xn) receives input signal and broadcasts to all units in hidden layer
  • Step 2.2 : Each hidden unit z = (z1, z2, ..., zj) sums its weighted input signals

zj = ∑wijxi+bj

  • Step 2.3 Apply activation function

aj = f(zj)

118 of 151

MLP with Back propagation Algorithm

  • Output layer
  • Step 2.4 : Each output unit z = (z1, z2, ..., zk) sums its weighted input signals

zk = ∑wjkaj+bk

  • Step 2.5 Apply activation function

yp = f(zk)

Step 3 : Backward Propagation Phase

  • Step 3.1 Compute Loss

Example (Mean Squared Error):

E = ½ * (y-yp)2

119 of 151

MLP with Back propagation Algorithm

  • Step 3.2 : Output layer error

δk=(y−yp)f′(yp)

  • Step 3.3 Hidden layer error

δj​=f′(aj​)∑δk ​wjk

Step 4 : Update weights

Step 4.1 Output weights:

wjk(new) ​=wjk(old)​+ηδk​aj

Step 4.2 Hidden weights:

wij(new​)=wij(old)​+ηδj​xi

Step 4.3 biases

b(new)=b(old)+ηδ

120 of 151

MLP with Back propagation Algorithm

  • Step 6: Repeat
  • Repeat steps 2–4 for:
  • All training samples
  • Multiple epochs

  • Until:
  • Error is minimized OR
  • Max iterations reached

121 of 151

MLP with Back propagation Algorithm

  • Algorithm Summary (Simple Steps)
  • Initialize weights & bias
  • Perform forward propagation
  • Compute error
  • Backpropagate error
  • Update weights & bias
  • Repeat until convergence

122 of 151

Example

  • Network Structure
  • Inputs: x1=1,  x2=0
  • Hidden layer: 2 neurons
  • Output: 1 neuron
  • Target:

y=1

  • Learning rate:

η=0.1

  • Activation: Sigmoid

123 of 151

Example

  • Step 1: Initialize Weights
  • Input → Hidden

w1=0.2,  w2=0.3,  b1=0.1

w3=0.4,  w4=0.1,  b2=0.1

  • Hidden → Output

w5=0.3,  w6=0.2,  b3=0.1

  • Step 2: Forward Propagation
  • Hidden Neuron 1

z1=(1)(0.2)+(0)(0.3)+0.1=0.3

a1​=σ(0.3)=0.574

124 of 151

Example

  • Hidden Neuron 2

z2=(1)(0.4)+(0)(0.1)+0.1=0.5

a2​=σ(0.5)=0.622

  • Output Neuron

z3=(0.574)(0.3)+(0.622)(0.2)+0.1

z3=0.172+0.124+0.1=0.396

yp=σ(0.396)=0.598

125 of 151

Example

  • Step 3 : Backward Propagation
  • Error Calculation

E=1/2​(1−0.598)2=0.081

  • Output Layer Gradient (or) Output Layer Error δ3​=(y−yp​)⋅yp​(1−yp​)

δ3=(1−0.598)(0.598)(0.402)

δ3​≈0.097

126 of 151

Example

  • Hidden Layer Gradient (or) Hidden Layer Error Error Calculation

Neuron 1:

δ1​=δ3​⋅w5​⋅a1​(1−a1​)

δ1=0.097⋅0.3⋅(0.574)(0.426)

δ1​≈0.007

Neuron 2:

δ2​=δ3​⋅w6​⋅a2​(1−a2​)

δ2=0.097⋅0.2⋅(0.622)(0.378)

δ2​≈0.005

127 of 151

Example

  • Step 5: Update Weights

Hidden → Output:

w5​=0.3+0.1(0.097)(0.574)≈0.306 w6=0.2+0.1(0.097)(0.622)≈0.206

b3 = 0.1 + 0.1(0.097) ≈ 0.109

128 of 151

Example

  • Input → Hidden

Neuron 1 :

w1​=0.2+0.1(0.007)(1)≈0.201

w2=0.3+0.1(0.007)(0)=0.3

b1 =0.1+0.1(0.007)≈ 0.101

Neuron 2:

w3​=0.4+0.1(0.005)(1)≈0.401

w4=0.1+0.1(0.005)(0)=0.1

b2​=0.1+0.1(0.005)≈0.1005

129 of 151

Example : Final Updated Values (After 1 Backpropagation Step)

Parameter

Old Value

New Value

w1

0.2

0.201

w2

0.3

0.300

W3

0.4

0.401

W4

0.1

0.100

W5

0.3

0.306

W6

0.2

0.206

b1

0.1

0.101

b2

0.1

0.1005

b3

0.1

0.109

130 of 151

MLP Algorithm Summary

  •  

131 of 151

MLP Algorithm Summary

  •  

132 of 151

Thank you

133 of 151

Parameters

  • Definition

Parameters are values learned automatically by the neural network during training.

  • They determine how the network makes predictions.
  • Examples

Weights (W)

Biases (b)

  • Characteristics

Learned from data.

Updated during backpropagation.

Directly affect predictions.

134 of 151

Hyperparameters

  • Definition

- Hyperparameters are values chosen before training.

- They control how the neural network learns, but they are not learned from the data.

Hyperparameter

Purpose

Learning Rate

Controls weight update size

Number of Hidden Layers

Controls network depth

Number of Neurons

Controls model capacity

Batch Size

Number of samples processed before updating weights

Number of Epochs

Number of complete training passes

Activation Function

Determines neuron output

Optimizer

Updates weights (SGD, Adam, RMSProp)

Dropout Rate

Helps prevent overfitting

135 of 151

Summary

  • Learned the fundamentals of Neural Networks and Deep Neural Networks.
  • Understood the importance of activation functions, loss functions, and function approximation in neural network learning.
  • Distinguished between classification and clustering problems and their real-world applications.
  • Compared shallow and deep neural networks and studied their architectures.
  • Learned how Gradient Descent, Forward Propagation, and Backpropagation train neural networks by minimizing prediction error.
  • Understood the difference between parameters (weights and biases) and hyperparameters (learning rate, epochs, batch size, etc.) and their role in model training.

136 of 151

Key Takeaways

  • Neural networks learn patterns by adjusting weights and biases.
  • Activation functions enable neural networks to learn complex, nonlinear relationships.
  • Loss functions quantify prediction errors during training.
  • Gradient Descent minimizes the loss by updating model parameters.
  • Backpropagation efficiently computes gradients using the chain rule.
  • Deep Neural Networks can solve more complex problems than shallow networks.
  • Parameters are learned during training, whereas hyperparameters are chosen before training.
  • A strong understanding of these fundamentals is essential for studying advanced deep learning models.

137 of 151

Thank you

"Deep learning is not about making machines think like humans; it's about teaching machines to learn from data. The stronger your foundation, the greater your innovations."

138 of 151

Additional problem

  • Network Structure

x1,x2→h1,h2→o

  • ​ Assume the following values.
  • Inputs

x1=0.5, x2=0.3

  • Target t=1
  • Weights
  • Input → Hidden:
  • w1=0.2, w2=0.4
  • w3=0.3,w4=0.1
  • Hidden → Output:
  • w5=0.5,w6=0.6

139 of 151

  • For simplicity, assume all biases are zero:

b1=b2=b3=0

  • Learning rate:

η=0.1

Hidden Layer activation Tanh

Output Layer activation Sigmoid

140 of 151

  •  

141 of 151

  •  

142 of 151

  •  

143 of 151

  •  

144 of 151

  •  

145 of 151

  •  

146 of 151

  •  

147 of 151

  •  

148 of 151

  •  

149 of 151

  •  

150 of 151

  •  

151 of 151

  •