Module 2
Module 2
[Module 2]
25 August 2025 1
Syllabus
25 August 2025 2
Lecture - 6
Rosenblatt’s Perceptron Model
25 August 2025 3
• A perceptron is a fundamental building block of neural
networks.
• It’s a simple computational unit inspired by the way
biological neurons work in the human brain.
Introducing Artificial Neural Networks Using the 7 Ws and 1 H
25 August 2025 4
Introducing Artificial Neural Networks Using the 7 Ws and 1 H
25 August 2025 5
Perceptron
25 August 2025 6
Structure of Perceptron
25 August 2025 7
Components of the Neuron Model
1. Linear Combiner:
▪ The linear combiner sums up the inputs received from various synapses,
which are weighted connections between neurons.
▪ Additionally, it incorporates an externally applied bias to adjust the sensitivity
of the model.
[Link] Local Field:
▪ This resulting sum, also referred to as the induced local field, represents the
total input to the neuron after weighting and bias adjustments.
[Link] Limiter:
▪ The induced local field is then passed through a hard limiter function.
▪ If the induced local field is positive, the output of the hard limiter is +1.
▪ If the induced local field is negative, the output is -1.
25 August 2025 8
Linear Threshold (LTU)
25 August 2025 9
Components
Weighted Sum of Inputs: Each input feature is multiplied by its
corresponding weight. The products of these multiplications are
then summed up to calculate the weighted sum of inputs.
25 August 2025 10
Perceptron
▪ The most common AF used in perceptron's is the step function or
the sign function.
▪ The step function outputs 1 if the weighted sum plus bias is
greater than or equal to zero, and 0 otherwise.
▪ This essentially makes the perceptron act as a simple threshold-
based binary classifier.
▪ Single perceptron can only learn linear decision boundaries,
which limits its ability to handle complex data.
▪ To overcome this limitation, multi-layer neural networks with
nonlinear activation functions (e.g., sigmoid, tanh, ReLU) are
used, enabling them to learn more intricate relationships in the
data.
25 August 2025 11
What can a Perceptron do ?
▪ The perceptron is an algorithm for supervised classification of an
input into one of several possible non-binary outputs.
▪ Perceptron can be defined as a single artificial neuron that computes
its weighted input with the help of the threshold activation function
or step function.
▪ It is used for binary Classification and only models linearly
separable classes.
▪ First, train a perceptron for a classification task.
▪ Find suitable weights in such a way that the training examples are
correctly classified.
25 August 2025 12
Perceptron
25 August 2025 13
Linear Separability
Linear Separable:
Linear inseparable:
Solution?
25 August 2025 14
Linear /Non-Linear Patterns
25 August 2025 15
Linear Separability
• Every logic function can be implemented by neural networks. So, the step function is
commonly used in primitive neural networks without a hidden layer or a widely
known name, such as a single-layer perceptron.
• This type of network can classify linearly separable problems, such as an AND
gate or an OR gate. In other words, all classes (0 and 1) can be separated by a single
linear line as illustrated below.
25 August 2025 16
25 August 2025 17
Limitations of Perceptron
25 August 2025 18
Perceptron Convergence Theorem
▪ It’s like a basic building block for understanding how computers make
decisions, much like our brains handle simple choices.
▪ Class C1: Inputs are classified as C1 if the output of the neuron model
is +1 (indicating a positive induced local field).
▪ Class C2: Inputs are classified as C2 if the output of the neuron model
is -1 (indicating a negative induced local field).
25 August 2025 19
25 August 2025 20
Bias b(n) is treated as a synaptic weight driven by a
fixed input equal to 1.
(m+1)-by-1 input vector, weight vector
n denotes the time-step
x(n) = [+1, x1(n), x2(n), ..., xm(n)]^T
w(n) = [b, w1(n), w2(n), ..., wm(n)]^T
the linear combiner output
25 August 2025 21
For fixed n, the equation w^T.x = 0, plotted in an m-dimensional
space (and for some prescribed bias) with coordinates x1, x2, ...,
xm, defines a hyperplane as the decision surface between two
different classes of inputs.
25 August 2025 22
Given the subsets of training vectors h1 and h2, the training
problem for the perceptron is then to find a weight vector w
satisfying the decision boundary equation.
25 August 2025 23
Lecture-7
Activation functions and Multilayer Perceptron
25 August 2025 24
Activation functions
▪ Activation functions determine the output of a neuron given an input. Common types
include
▪ The step function outputs a binary value (0/1) based on a threshold.
▪ The sign function outputs -1 or 1 depending on the input's sign.
▪ The sigmoid function outputs a value between 0 and 1, introducing smooth non-linearity
▪ The linear function outputs the input directly, often used in the final layer for regression
tasks.
▪ The combination of these functions helps the network learn various data patterns.
▪ The choice of activation function affects the network's capacity to capture complex
relationships.
25 August 2025 25
Sigmoid Unit
kth sigmoid unit
x1 wk1
x.2 wk2
.
. . ok
. .
xm wkm
bk
1
ok = f ( yk ) =
1 +e- y
k
25 August 2025 26
25 August 2025 27
Example
25 August 2025 28
25 August 2025 29
Multilayer Perceptron
25 August 2025 30
Multilayer Perceptron (MLP)
Input Layer
25 August 2025 31
Features of MLP
25 August 2025 32
Types of Layers
25 August 2025 34
Multilayer perceptron with two hidden layers
25 August 2025 37
Function of the Hidden Neurons
▪ The hidden neurons act as feature detectors; play a critical role in the operation
of a multilayer perceptron.
▪ As the learning process progresses across the MLP, the hidden neurons begin to
gradually “discover” the salient features that characterize the training data.
▪ They do so by performing a nonlinear transformation on the input data into a
new space called the feature space.
▪ In this new space, the classes of interest in a pattern-classification task, for
example, may be more easily separated from each other than could be the case in
the original input data space.
▪ Formation of this feature space through supervised learning distinguishes the
multilayer perceptron from Rosenblatt’s perceptron.
25 August 2025 38
Task of hidden neurons
[Link]
25 August 2025 41
Lecture 8 - 9
25 August 2025 42
Gradient Descent
▪ Training data helps models learn over time, and the cost function
within gradient descent specifically acts as a barometer,
calculating its accuracy with each iteration of parameter updates.
25 August 2025 43
Delta Rule
25 August 2025 45
Error Function / Cost Function
▪ Delta Rule employs the error function for what is known as Gradient Descent
learning, which involves the ‘modification of weights along the most direct path
in weight-space to minimize error’, so the change applied to a given weight is
proportional to the negative of the derivative of the error with respect to that
weight.
▪ The Error/Cost function is commonly given as the sum of the squares of the
differences between all target and actual node activation for the output layer.
▪ For a particular training pattern (i.e., training case), error Ep
▪ ‘Ep’ - total error over the training pattern,
▪ ½ - value applied to simplify the function’s derivative
▪ ’n’ - all output nodes for a given training pattern
▪ ‘tj’ sub n - Target value for node n in output layer j,
▪ ‘aj’ sub n - actual activation for the same node.
▪ This particular error measure is attractive because its derivative, whose value is
needed in the employment of the Delta Rule, and is easily calculated.
25 August 2025 46
25 August 2025 47
25 August 2025 48
25 August 2025 49
25 August 2025 50
25 August 2025 51
E = 1
wi wi 2 dD
(td − od )2
Sigmoid function
= 1 (td − od )2
2 dD wi
= 1 2(td − od ) (td − od )
2 dD wi
= −(t d − od ) od
dD wi
yd
= −(t d − od ) od chain rule
dD
yd wi
n
1 ( xiwi)
= − (t d − od ) ( ) i=0
Sigmoid
dD yd 1+ e − yd
wi function
= − (t d − od )od (1− od )xi Continue….
dD
25 August 2025 52
wi = − E = (t d − od )od (1− od )xi
wi dD
[Link]
25 August 2025 53
How Gradient Descent Optimization Works for Minimizing Error
➢ The goal is to find the value that minimizes (the pink point in the
figure below).
➢ To achieve that point, use the gradient information, where the
gradient represents the slope of the function.
➢ Positive gradient, the curve will increase when the error increases.
➢ [Link]
Negative gradient, the curve will decrease when error increases.
➢ Thus, how to update weights so that error decreases constantly?
The answer is by subtracting the existing weight from the gradient.
➢ What step should be made in every iteration update?
➢ The learning rate is a tuning parameter that determines the step
size at each iteration of gradient descent. It determines the speed at
which we move down the slope.
25 August 2025 54
➢ Assume Y = f(x) = (1/2)x^2.
➢ How to reach the pink point
minimizing Y value, i.e., the pink
point will be x = 0.
➢ Assume the current x = 10.
25 August 2025 55
[Link]
25 August 2025 56
Batch Learning and Online Learning
25 August 2025 57
Batch Learning
• Batch learning, also known as offline learning or batch training,
involves training a machine learning model using the entire dataset
at once.
• In this approach, the model is trained on a fixed dataset, often
referred to as a "batch," and its parameters are updated after
processing the entire batch.
• The model learns from the patterns present in the entire batch and
adjusts its parameters to minimize a specified loss function.
25 August 2025 58
Advantages and disadvantages of batch learning
25 August 2025 60
Advantages and disadvantages of online learning
25 August 2025 61
• In practice, the choice between batch learning and
online learning depends on the nature of the problem,
the available computational resources, the
characteristics of the data, and the desired update
frequency of the model.
• Some hybrid approaches also exist, where models are
updated in small batches at regular intervals to balance
between efficiency and model stability.
25 August 2025 62
Lecture 10-11
The Back-Propagation Algorithm
25 August 2025 63
Back-Propagation
25 August 2025 64
Back-Propagation
25 August 2025 65
The Back-Propagation Algorithm
Forward
Backward
➢ Method for learning weights in feed-forward (FF) nets uses gradient descent to
minimize the error, propagating deltas to adjust for errors backward from outputs
to hidden layers to inputs.
➢ The idea of the algorithm can be summarized as follows :
1. Computes the error term for the output units using the observed error.
2. From the output layer, repeat
• propagating the error term back to the previous layer
• updating the weights between the two layers until the earliest hidden layer is
reached.
25 August 2025 66
Steps in the Back Propagation Algorithm
25 August 2025 67
Propagation through Hidden Layer (One Node )
-
x0 w0j
x1 w1j
f
output y
xn wnj
25 August 2025 68
Propagate the inputs forward
For unit j in the input layer, its output is equal to its input, that is,
for input unit j.
Oj = I j
The net input to each unit in the hidden and output layers is
computed as follows.
• Given a unit j in a hidden or output layer, the net input is
I j = wij Oi + j
i
where wij is the weight of the connection from unit i in the previous
layer to unit j; Oi is the output of unit I from the previous layer;
j
is the bias of the unit
25 August 2025 69
Propagate the inputs forward
Each unit in the hidden and output layers takes its net input and then
applies an activation function.
25 August 2025 70
Back propagate the error
When reaching the Output layer, the error is computed and
propagated backwards.
For a unit k in the output layer, the error is computed by a formula:
Errk = Ok (1 − Ok )(Tk − Ok )
Where Ok – actual output of unit k ( computed by activation function.
1
Ok = −Ik
1+ e
25 August 2025 71
Update weights and biases
j = (l) Errj
j = j + j
25 August 2025 72
Terminating Conditions
Updating weights and biases after the presentation of each sample
• All wij in the previous epoch are below some threshold.
case.
Epoch --- One iteration through the training set is called an epoch.
• The percentage of samples misclassified in the previous
epoch
Epoch is below
updating some threshold.
------------
25 August 2025 73
Backpropagation Formulas
Output vector
Errk = Ok (1 − Ok )(Tk − Ok )
Output nodes
1 Err j = O j (1 − O j ) Errk w jk
Oj = −I j k
1+ e
Hidden nodes
Input vector: xi
25 August 2025 74
Example of Back Propagation
Initialize weights :
25 August 2025 75
Example ( cont.. )
+ Output nodes
Initialize Bias
-1.0 to 1.0
Bias ( Random )
θ4 θ5 θ6
-0.4 0.2 0.1
25 August 2025 76
Net Input and Output Calculation
(-0.3)0.332-(0.2)(0.525)+0.1= -0.105 1
6 Oj = = 0.475
1 + e0.105
25 August 2025 77
Calculation of Error at Each Node
Unit j Error j
6 0.475 x (1-0.475)(1-0.475)=0.1311
We assume T 6 = 1
25 August 2025 78
Calculation of Weights and Bias Updating
Learning Rate l =0.9
……..similarly ………similarly
25 August 2025 79
25 August 2025 80
25 August 2025 81
25 August 2025 82
25 August 2025 83
25 August 2025 84
25 August 2025 85
25 August 2025 86
25 August 2025 87
25 August 2025 88
25 August 2025 89
Lecture 12-15
Multilayer Perceptron Applications and
more problems on backpropagation
25 August 2025 90
Tangent hyperbolic activation function
25 August 2025 91
Perform backpropagation algorithm on the given network
using the tangent function as activation on both hidden
and output layers. I/p [1,1] Target O/p [0]
25 August 2025 92
Multilayer Perceptron Applications
1. Image Classification
2. Speech Recognition
3. Financial Prediction and Risk Management
4. Medical Diagnosis
5. Anomaly Detection
MLPs are typically used for supervised learning problems
where the aim is to learn a function that maps input data to
appropriate output labels.
25 August 2025 93
Image Classification with MLP
25 August 2025 94
How MLP Works for Image Classification
Input Layer:
➢ The input layer receives the raw pixel values of the image. For example,
for a grayscale image of 28x28 pixels, the input layer would have 784
neurons (28 * 28).
➢ Each neuron in the input layer represents a pixel value, typically
normalized to a range between 0 and 1.
Hidden Layers:
➢ The hidden layers in the MLP are responsible for learning the features
from the input data.
➢ These layers apply a series of linear transformations followed by a non-
linear activation function.
➢ The depth number of hidden layers and width number of neurons per
layer are hyperparameters that can be tuned for optimal performance.
25 August 2025 95
How MLP Works for Image Classification
Output Layer:
o The output layer is usually a SoftMax layer in image classification
tasks. If there are n classes, the output layer will have n neurons.
o The SoftMax function converts the raw output scores into
probabilities, with each neuron’s output representing the
probability that the input image belongs to a particular class.
Training:
o The MLP is trained using a labeled dataset. The training process
involves adjusting the weights and biases of the neurons using
backpropagation and gradient descent to minimize the loss
function.
o Common loss functions for classification tasks include Cross-
Entropy Loss.
25 August 2025 96
Example of MLP in Image Classification
Let's consider the task of classifying handwritten digits from the
MNIST dataset using an MLP.
Dataset:
o The MNIST dataset consists of 60,000 training images and 10,000
testing images of handwritten digits (0-9). Each image is 28x28
pixels in size.
MLP Architecture:
o Input Layer: 784 neurons (for 28x28 pixel images)
o Hidden Layer 1: 128 neurons with ReLU activation
o Hidden Layer 2: 64 neurons with ReLU activation
o Output Layer: 10 neurons with SoftMax activation (one for each
digit 0-9)
25 August 2025 97
25 August 2025 98
25 August 2025 99
Applications of MLP in Image Classification
Although MLPs are not the first choice for image classification, they
can still be used in scenarios such as:
• Simple Image Classification Tasks: Where the image data is small
and less complex, MLPs can perform sufficiently well.
• Feature Extraction: MLPs can be used as a feature extractor where
the final classification is done using another classifier.
• Dimensionality Reduction: MLPs can also help in reducing the
dimensionality of the data, capturing the most important features
before passing it to a more complex model like a CNN.
XOR, which stands for exclusive OR, is a logical operation that takes
two binary inputs and returns true if exactly one of the inputs is true.
The XOR gate follows a specific truth table, where the output is true
only when the inputs differ.
3
w13 −1
x1 1 3 w35
w23 5
5 y5
w24
x2 2 4 w45
w24
Input 4 Output
layer layer
−1
Hidden layer
Final results of three-layer network learning
-1.5
1
+1.0
x1 1 3 -2 -0.5
+1.0
5 y5
+1.0
x2 2 +1.0
4
+1.0
-0.5
1
[Link]