ML Unit 2
ML Unit 2
ENGINEERING
UNIT – II
Multi-layer Perceptron– Going Forwards – Going Backwards: Back
Propagation Error – Multi-layer Perceptron in Practice – Examples of
using the MLP – Overview – Deriving Back-Propagation – Radial
Basis Functions and Splines – Concepts – RBF Network – Curse of
Dimensionality – Interpolations and Basis Functions – Support Vector
Machines
MALLA REDDY COLLEGE OF
ENGINEERING
UNIT – II – Multi-layer Perceptron Going Forwards – Going Backwards: Back Propagation Error – Multi-layer Perceptron in Practice – Examples of using the
MLP – Overview – Deriving Back-Propagation – Radial Basis Functions and Splines – Concepts – RBF Network – Curse of Dimensionality – Interpolations and Basis
Functions – Support Vector Machines
Multi-layer Perceptron :
The multilayer perceptron is an artificial neural network structure and is a nonparametric estimator that can be used
for classification and regression. We discuss the back propagation algorithm to train a multilayer perceptron for a
variety of applications.
We have pretty much decided that the learning in the neural network happens in the weights. So, to perform more
computation it seems sensible to add more weights. There are two things that we can do:
add some backwards connections, so that the output neurons connect to the inputs again, or add more
neurons.
The first approach leads into recurrent networks. These have been studied, but are not that
commonly used.We will instead consider the second approach.
MALLA REDDY COLLEGE OF
ENGINEERING
UNIT – II – Multi-layer Perceptron Going Forwards – Going Backwards: Back Propagation Error – Multi-layer Perceptron in Practice – Examples of using the MLP
– Overview – Deriving Back-Propagation – Radial Basis Functions and Splines – Concepts – RBF Network – Curse of Dimensionality – Interpolations and Basis Functions –
Support Vector Machines
Multi-layer Perceptron :.
MALLA REDDY COLLEGE OF ENGINEERING
UNIT – II Multi-layer Perceptron – Going Forwards – Going Backwards: Back Propagation Error – Multi-layer Perceptron in Practice – Examples of using the
MLP – Overview – Deriving Back-Propagation – Radial Basis Functions and Splines – Concepts – RBF Network – Curse of Dimensionality – Interpolations and Basis
Functions – Support Vector Machines
Multi-layer Perceptron :.
we can check that a prepared network can solve the two-dimensional XOR problem, something that we have seen is
not possible for a linear model like the Perceptron.
A suitable network is shown in Figure 4.2. To check that it gives the correct answers, all that is required is to put in
each input and work through the network, treating it as two different Perceptrons, first computing the activations of
the neurons in the middle layer (labelled as C and D in Figure 4.2) and then using those activations as the inputs to the
single neuron at the output. As an example, I’ll work out what happens when you put in (1, 0) as an input;
MALLA REDDY COLLEGE OF
ENGINEERING
UNIT – II – Multi-layer Perceptron Going Forwards – Going Backwards: Back Propagation Error – Multi-layer Perceptron in Practice – Examples of using the
MLP – Overview – Deriving Back-Propagation – Radial Basis Functions and Splines – Concepts – RBF Network – Curse of Dimensionality – Interpolations and Basis
Functions – Support Vector Machines
Multi-layer Perceptron :.
A suitable network is shown in Figure 4.2. To check that it gives
the correct answers, all that is required is to put in each input and
work through the network, treating it as two different
Perceptrons, first computing the activations of the neurons in the
middle layer (labelled as C and D in Figure 4.2) and then using
those activations as the inputs to the single neuron at the output.
As an example, I’ll work out what happens when you put in (1, 0)
as an input;
MALLA REDDY COLLEGE OF
ENGINEERING
–
UNIT – II Multi-layer Perceptron Going Forwards – Going Backwards: Back Propagation Error – Multi-layer Perceptron in Practice – Examples of using the MLP – Overview – Deriving Back-Propagation – Radial Basis Functions and Splines –
Concepts – RBF Network – Curse of Dimensionality – Interpolations and Basis Functions – Support Vector Machines
Z1= 𝑥1𝑥2
w1
x1 Z1 1 1 0
w2
x2 𝑦 = 𝑥1𝑥2 + 𝑥1x2
{0 Yin<0
MALLA REDDY COLLEGE OF
ENGINEERING
UNIT – II – Multi-layer Perceptron Going Forwards – Going Backwards: Back Propagation Error – Multi-layer Perceptron in Practice – Examples of using the MLP –
Overview – Deriving Back-Propagation – Radial Basis Functions and Splines – Concepts – RBF Network – Curse of Dimensionality – Interpolations and Basis Functions –
Support Vector Machines
X1 X2 Z
Multi-layer Perceptron with XOR
0 0 0
Let us consider the weights for w11 = 1 w21 =1 0 1 0
- wij =wij +n(t-o)xi ∴ -w11 = 1+1.5 *(0-1)*0=0 w21 = 1+1.5 * (0-1) * 1 = -0.5
MALLA REDDY COLLEGE OF
ENGINEERING
UNIT – II – Multi-layer Perceptron Going Forwards – Going Backwards: Back Propagation Error – Multi-layer Perceptron in Practice – Examples of using the
MLP – Overview – Deriving Back-Propagation – Radial Basis Functions and Splines – Concepts – RBF Network – Curse of Dimensionality – Interpolations and Basis
Functions – Support Vector Machines
X1 X2 Z1
Multi-layer Perceptron with XOR
First function = Z1= 𝑥1𝑥2
0 0 0
0 1 0
Let us consider the weights for w11 = 1 w21 =1 updated weights:w11= 1, w21= -
1 0 1
0.5 Threshold = 1 learning rate = 1.5
1 1 0
(0,0) Zin = Wij*Xi = 1*0+(-0.5)*0 = 0 (out = 0)
- wij =wij +n(t-o)xi ∴ -w11 = 1+1.5 *(0-1)*0=1 w21 = 1+1.5 * (0-1) * 1 = -0.5
MALLA REDDY COLLEGE OF
ENGINEERING
–
UNIT – II Multi-layer Perceptron Going Forwards – Going Backwards: Back Propagation Error – Multi-layer Perceptron in Practice – Examples of using the MLP – Overview – Deriving Back-Propagation – Radial Basis Functions and Splines –
Concepts – RBF Network – Curse of Dimensionality – Interpolations and Basis Functions – Support Vector Machines
z2 = 𝑥1x2
1 0 1
x1 1 1 0
W1 2
𝑦 = 𝑥1𝑥2 + 𝑥1x2
x2 W2 2
Z1
f(Yn) = {1 if Yin≥0 Activation Function
{0
Yin<0
MALLA REDDY COLLEGE OF
ENGINEERING
UNIT – II – Multi-layer Perceptron Going Forwards – Going Backwards: Back Propagation Error – Multi-layer Perceptron in Practice – Examples of using the
MLP – Overview – Deriving Back-Propagation – Radial Basis Functions and Splines – Concepts – RBF Network – Curse of Dimensionality – Interpolations and Basis
Functions – Support Vector Machines
X1 X2 Z2
Multi-layer Perceptron with XOR
First function = z2 = 𝑥1x2
0 0 0
0 1 1
Let us consider the weights for w12 = 1 w2 2 = 1 updated weights:w12= -0.5, w2 2=1 1 0 0
Threshold = 1 learning rate = 1.5 1 1 0
- wij =wij +n(t-o)xi ∴ -w12 = 1+1.5 *(0-1)* 1=-0.5 w22 = 1+1.5 * (0-1) * 0 = 1
MALLA REDDY COLLEGE OF
ENGINEERING
UNIT – II – Multi-layer Perceptron Going Forwards – Going Backwards: Back Propagation Error – Multi-layer Perceptron in Practice – Examples of using the MLP – Overview – Deriving Back-
Propagation – Radial Basis Functions and Splines – Concepts – RBF Network – Curse of Dimensionality – Interpolations and Basis Functions – Support Vector Machines
- wij =wij +n(t-o)xi ∴ -w12 = 1+1.5 *(0-1)* 1=-0.5 w22 = 1+1.5 * (0-1) * 0 = 1
MALLA REDDY COLLEGE OF
•ENGINEERING
Y = Z1 OR Z2
• => yin = Z1v1 +z2v2
• => v1 = 1 ; v2 = 1 X1 X2 Z1 Z2 Y
Threshold = 1 and learning rate = 1.5 0 0 0 0 0
0 1 0 1 1
(0,0) -> yin = vi * xi = 1*0+1*0 = 0 (out =0) 1 0 1 0 1
(0,1) -> yin = vi*xi = 1*0+1*1 = 1 (out = 1) 1 1 0 0 0
w11
x1 z1
x1
w12
w21 Y Y
x2 x2 z2
w22
MALLA REDDY COLLEGE OF
ENGINEERING
• In machine learning, backpropagation is an effective algorithm used to train
To the weighted sum of inputs, the activation function is applied in the hidden layer to each of its neurons.
One such activation function that is commonly used is ReLU can also be used, which is responsible for
returning the input if it is positive otherwise it returns zero. By doing this so, it introduces the non-linearity to
our model, which enables the network to learn the complex relationships in the data. And finally, the
weighted outputs from the last hidden layer are fed into the output to compute the final prediction, this
layer can also use the activation function called the softmax function which is responsible for converting the
weighted outputs into probabilities for each class.
MALLA REDDY COLLEGE OF
ENGINEERING
The Backpropagation algorithm works by two different passes, they are:
Forward pass
MALLA REDDY COLLEGE OF
ENGINEERING
The Backpropagation algorithm works by two different passes, they are: Backward pass
• In the backward pass process shows, the error is transmitted back to the network
which helps the network, to improve its performance by learning and adjusting the
internal weights.
• To find the error generated through the process of forward pass, we can use one of the
most commonly used methods called mean squared error which calculates the difference
between the predicted output and desired output. The formula for mean squared error is:
Mean squared error = (predicted output – actual output)^2
• Once we have done the calculation at the output layer, we then propagate the error
backward through the network, layer by layer.
• The key calculation during the backward pass is determining the gradients for each
weight and bias in the network. This gradient is responsible for telling us how much each
weight/bias should be adjusted to minimize the error in the next forward pass. The chain
rule is used iteratively to calculate this gradient efficiently.
• In addition to gradient calculation, the activation function also plays a crucial role in
backpropagation, it works by calculating the gradients with the help of the derivative of
MALLA REDDY COLLEGE OF
ENGINEERING
the activation function.
MALLA REDDY COLLEGE OF
ENGINEERING
Working of Backpropagation
part 1:
calculate forward
propagation error W1(0.15) W5(0.40) 0.01
0.05 h1 O1
calculate h1(in and x1
out) where h1 =
w1x1+w2x2+b1
𝟏
b1= (0.35) b2= (0.60)
H2 (out) =
𝟏+𝒆−𝟎.𝟑𝟗𝟐𝟓
= 0.5968
MALLA REDDY COLLEGE OF
ENGINEERING
Working of Backpropagation Algorithm with an
example
part 3:
calculate forward propagation error
calculate O1(in and out)
W1(0.15) W5(0.40) 0.01
x1 0.05 h1 O1
where O1 = h1(out)*w5+h2(out)*w6+b2
O1(in)
= 0.593*0.4+0.596*0.45+0.6
= 1.105
0.99
𝟏 x2 0.10 h2 O2
O1 (out) =
𝟏+𝒆−𝑶𝟏(𝒊𝒏)
W4 (0.30) W8 (0.55)
𝟏
b1= (0.35) b2= (0.60)
H2 (out) =
𝟏+𝒆−𝟏.𝟏𝟎𝟓
= 0.7513
MALLA REDDY COLLEGE OF
ENGINEERING
Working of Backpropagation Algorithm with an
example
part 3:
calculate forward propagation error
calculate O2(in and out)
W1(0.15) W5(0.40) 0.01
x1 0.05 h1 O1
where O2 = h1(out)*w7+h2(out)*w8+b2
O2(in)
= 0.5932*0.50+0.5968*0.55+0.6
= 1.22484
0.99
𝟏 x2 0.10 h2 O2
=
𝟏+𝒆−𝑶𝟐(𝒊𝒏)
O2 (out) W4 (0.30) W8 (0.55)
𝟏
b1= (0.35) b2= (0.60)
H2 (out) =
𝟏+𝒆−𝟏.𝟐𝟐𝟒𝟖𝟒
= 0.7729
MALLA REDDY COLLEGE OF
ENGINEERING
Working of Backpropagation Algorithm with an
example
part 3:
calculate forward propagation error
𝟏
Etotal = ∑ 𝒕𝒂𝒓𝒈𝒆𝒕 −
calculate E total where E represents Error
𝟐
𝑶𝒖𝒕𝒑𝒖𝒕
0.01
W1(0.15) W5(0.40)
h1 O1
𝟐
x1 0.05
𝝏 𝑾𝟓
where
Where n is Learning Rate with 0.6
𝝏𝑬𝒕𝒐𝒕
W4 (0.30) W8 (0.55)
=Out O1 – Target O1
𝒂𝒍
b1= (0.35) b2= (0.60)
𝝏 𝒐𝒖𝒕
= 0.751365-0.01 =
𝑶𝟏
0.7413565
𝝏 𝑶𝒖𝒕 𝑶𝟏
𝝏 𝒏𝒆𝒕 𝑶𝟏
= Out O1 (1-Out O1)
MALLA REDDY COLLEGE OF
= 0.751365(1-0.751365)
ENGINEERING
= 0.186815602
MALLA REDDY COLLEGE OF ENGINEERING
Working of Backpropagation Algorithm with an
example
part 3:
calculate Backward propagation error
(output layer to hidden layer)
W5,W6,W7,W8 W1(0.15) W5(0.40) 0.01
𝝏𝑬𝒕𝒐𝒕𝒂𝒍
x1 0.05 h1 O1
*W5 = W5-n ∂ Partial Differential
𝝏 𝑾𝟓
where
Where n is Learning Rate with 0.6
𝝏 𝑶𝒖𝒕 𝑶𝟏
𝝏 𝒏𝒆𝒕 𝑶𝟏
= Out O1 (1-Out O1)
= 0.751365(1-0.751365)
= 0.186815602
MALLA REDDY COLLEGE OF ENGINEERING
Working of Backpropagation Algorithm with an
example
part 3:
calculate Backward propagation error
(output layer to hidden layer)
W5,W6,W7,W8 W1(0.15) W5(0.40) 0.01
𝝏𝑬𝒕𝒐𝒕𝒂𝒍
x1 0.05 h1 O1
*W5 = W5-n ∂ Partial Differential
𝝏 𝑾𝟓
where
Where n is Learning Rate with 0.6
𝝏 𝑾𝟓
0.7413565*0.186815602*0.59326992 b1= (0.35) b2= (0.60)
= 0.08216704
W5* = W5 - n 𝑬𝒕𝒐𝒕𝒂𝒍
𝝏
𝝏 𝑾𝟓
=
= 0.350699776
0
.
4
-
(
0
.
6
*
0
.
0
8
2
1
6
7
0
4
)
MALLA REDDY COLLEGE OF ENGINEERING
Working of Backpropagation Algorithm with an
example
part 3:
calculate Backward propagation error
(hidden layer to input layer )
W1,W2,W3,W4 W5(0.40) 0.01
W1(0.15) h1 O1
*W1 = W1- x1 0.05
n𝝏𝑬𝒕𝒐𝒕𝒂𝒍
𝝏 𝑾𝟏
𝝏𝑬𝒕𝒐𝒕 𝝏 𝒐𝒖𝒕 𝝏 𝒏𝒆𝒕 𝒉𝟏
𝒂𝒍 𝝏𝑬𝒕𝒐𝒕𝒂𝒍 *
𝒉𝟏 𝝏 𝑾𝟏
𝝏 𝒐𝒖𝒕 𝝏 𝒏𝒆𝒕
= *
𝝏 𝑾𝟏
𝒉𝟏 𝒉𝟏
𝝏𝑬 𝑶𝟏 𝝏𝑬 𝑶𝟐
𝝏𝑬𝒕𝒐𝒕
0.99
= 𝝏 𝒐𝒖𝒕 𝒉𝟏 𝝏 +
𝒐𝒖𝒕 𝒉𝟏
h2 O2
𝒂𝒍
x2 0.10
W4 (0.30) W8 (0.55)
𝝏 𝒐𝒖𝒕
𝒉𝟏 𝝏 𝒐𝒖𝒕 𝝏 𝒏𝒆𝒕 𝑶𝟏
𝝏𝑬 𝑶𝟏 𝒉𝟏
𝝏𝑬 𝑶𝟏 𝝏𝒏𝒆𝒕 𝑶𝟏 b1= (0.35) b2= (0.60)
𝝏𝑬 𝑶𝟐 = * 𝝏𝑬 𝑶𝟐
𝝏 𝒏𝒆𝒕 𝑶𝟐
=
𝝏 𝒐𝒖𝒕
𝑶𝟏
𝝏𝒏𝒆𝒕
*𝑶𝟐
𝝏 𝒐𝒖𝒕 𝒉𝟏
MALLA REDDY COLLEGE OF ENGINEERING
Working of Backpropagation Algorithm with an
example
part 3:
calculate Backward propagation error
(hidden layer to input layer )
W1,W2,W3,W4 W1(0.15) W5(0.40) 0.01
0.05 h1 O1
x1
𝝏𝑬 𝑶𝟏 𝝏𝑬 𝑶𝟏 𝝏𝒏𝒆𝒕 𝑶𝟏
𝝏 𝒐𝒖𝒕 𝒉𝟏
=
𝝏 𝒐𝒖𝒕 𝒉𝟏 𝝏 𝒏𝒆𝒕
*
𝑶𝟏 𝝏𝒏𝒆𝒕 𝑶𝟐
𝝏 𝒐𝒖𝒕 𝒉𝟏
𝝏𝑬 𝑶𝟐
𝝏𝑬 𝑶𝟐 𝝏𝒐𝒖𝒕 𝑶𝟐
0.99
x2 0.10 h2 O2
= W4 (0.30) W8 (0.55)
𝝏 𝒐𝒖𝒕 𝒉𝟏 𝝏 𝒏𝒆𝒕
*
𝑶𝟐
𝝏𝑬 𝑶𝟐 𝝏𝑬 𝑶𝟐
𝝏 𝒏𝒆𝒕
𝝏 𝒏𝒆𝒕
=
𝑶𝟐
𝑶𝟐
𝝏 𝒐𝒖𝒕 𝑶𝟐
* b1= (0.35) b2= (0.60)
𝝏𝑬 𝑶𝟐 =
𝝏 𝒐𝒖𝒕 𝑶𝟐
(out O2- target O2)
= 0.772928465-0.99
= -0.2170771535
𝝏𝒐𝒖𝒕
𝑶𝟐 = out O2 – (1-out O2)
𝝏 𝒏𝒆𝒕 = 0.772928465 – (1- 0.772928465)
𝑶𝟐 = 0.175510052
MALLA REDDY COLLEGE OF ENGINEERING
Working of Backpropagation Algorithm with an
example
part 3:
calculate Backward propagation error
(hidden layer to input layer )
W1,W2,W3,W4 W1(0.15) W5(0.40) 0.01
0.05 h1 O1
x1
𝝏𝑬 𝑶𝟏 𝝏𝑬 𝑶𝟏 𝝏𝒏𝒆𝒕 𝑶𝟏
𝝏 𝒐𝒖𝒕 𝒉𝟏 𝝏 𝒏𝒆𝒕 𝑶𝟏 𝝏 𝒐𝒖𝒕 𝑶𝟏
= *
𝝏𝑬 𝑶𝟐 𝝏𝒏𝒆𝒕 𝑶𝟐
𝝏𝑬 𝑶𝟐
= 𝝏 𝒐𝒖𝒕 𝒉𝟏
𝝏𝒐𝒖𝒕 𝑶𝟐
0.99
𝝏 𝒐𝒖𝒕 𝒉𝟏 𝝏 𝒏𝒆𝒕
* x2 0.10 h2 O2
𝑶𝟐
W4 (0.30) W8 (0.55)
𝝏𝑬 𝑶𝟐 𝝏𝑬 𝑶𝟐
𝝏 𝒏𝒆𝒕
𝝏 𝒏𝒆𝒕
=
𝑶𝟐
𝑶𝟐
𝝏 𝒐𝒖𝒕 𝑶𝟐
* b1= (0.35) b2= (0.60)
𝝏𝑬 𝑶𝟐 =
𝝏 𝒐𝒖𝒕 𝑶𝟐
(out O2- target O2)
𝝏 𝒏𝒆𝒕
𝝏𝒐𝒖𝒕 𝑶𝟐 𝑶𝟐
= 0.772928465-0.99
𝝏𝑬
𝑶𝟐
= 5 – (1- 0.772928465) = -0.2170771535 * 0.175510052
𝝏 𝒏𝒆𝒕
- = 0.175510052
=
𝑶𝟐
0.
2 = on total of O2 from h1 => W7
1 𝝏𝒏𝒆𝒕
𝑶𝟐
= 0.50
𝝏 𝒐𝒖𝒕
7
𝒉𝟏
0
7
7
1
5
3
5
= out
O2 –
(1-
out
O2)
=
0.77
292
846
MALLA REDDY COLLEGE OF ENGINEERING
Working of Backpropagation Algorithm with an
example
part 3:
calculate Backward propagation error
(hidden layer to input layer )
W1,W2,W3,W4 W1(0.15) W5(0.40) 0.01
0.05 h1 O1
x1
𝝏𝑬 𝑶𝟏 𝝏𝑬 𝑶𝟏 𝝏𝒏𝒆𝒕 𝑶𝟏
𝝏 𝒐𝒖𝒕 𝒉𝟏
=
𝝏 𝒐𝒖𝒕 𝒉𝟏 𝝏 𝒏𝒆𝒕
*
𝑶𝟏 𝝏𝒏𝒆𝒕 𝑶𝟐
𝝏 𝒐𝒖𝒕 𝒉𝟏
𝝏𝑬 𝑶𝟐 𝝏𝑬 𝑶𝟐
𝝏 𝒐𝒖𝒕 𝒉𝟏 𝝏 𝒏𝒆𝒕
= 0.99
𝑶𝟐
x2 0.10 h2 O2
W4 (0.30) W8 (0.55)
= -0.03809823 * 0.50
𝝏𝑬 𝑶𝟐 𝝏𝑬 𝑶𝟐 𝝏𝒐𝒖𝒕 𝑶𝟐
𝝏 𝒏𝒆𝒕 𝑶𝟐 𝝏 𝒐𝒖𝒕 𝑶𝟐 𝝏 𝒏𝒆𝒕 𝑶𝟐
= * b1= (0.35) b2= (0.60)
𝝏𝑬 𝑶𝟐
𝝏𝒐𝒖𝒕 𝑶𝟐
O2)
𝝏 𝒐𝒖𝒕 = (out
𝑶𝟐 𝝏 𝒏𝒆𝒕 𝑶𝟐 O2- = 0.772928465-0.99
target = -0.2170771535
𝝏𝑬 𝑶𝟐
= out
𝝏 𝒏𝒆𝒕 𝑶𝟐
O2 – =-
(1- 0.217
out 𝝏𝒏𝒆𝒕 𝑶𝟐 07715
O2) 𝝏 𝒐𝒖𝒕 𝒉𝟏 35 *
= 0.1755
0.77 = 10052
2928 0.175510052 =-
465 0.038
– (1- 0982
0.77 3
2928
= on
465)
total of
O2
from h1
=> W7
= 0.50
MALLA REDDY COLLEGE OF ENGINEERING
Working of Backpropagation Algorithm with an
example
part 3:
calculate Backward propagation error
(hidden layer to input layer )
W1,W2,W3,W4 W1(0.15) W5(0.40) 0.01
0.05 h1 O1
𝝏𝑬 𝑶𝟏 𝝏𝑬 𝑶𝟏 𝝏𝒏𝒆𝒕 𝑶𝟏
x1
𝝏 𝒐𝒖𝒕 𝒉𝟏= 𝝏 𝒏𝒆𝒕 𝑶𝟏 𝝏 𝒐𝒖𝒕
* 𝒉𝟏
=0.37257738*0.4
𝝏𝑬 𝝏𝑬 * 𝝏𝒏𝒆 𝑶
𝑶𝟐 𝑶𝟐 𝒕 𝟐
=
�𝒐𝒖 𝒉 𝝏 𝑶 𝝏 𝒉
�𝒕 𝟏 𝒏𝒆𝒕 𝟐 𝒐𝒖𝒕 𝟏
0.99
x2 0.10 h2 O2
W4 (0.30) W8 (0.55)
𝝏𝑬 𝑶𝟏 𝝏𝑬 𝑶𝟏 𝝏𝒐𝒖𝒕 𝑶𝟏
𝝏 𝒏𝒆𝒕 𝑶𝟏 𝝏 𝒐𝒖𝒕 𝑶𝟏* 𝝏 𝒏𝒆𝒕 𝑶𝟏
= b1= (0.35) b2= (0.60)
𝝏𝑬 𝑶𝟏 𝝏 𝒏𝒆𝒕 𝑶𝟏 = 0.7513-0.01 = 0.7413
𝝏 𝒐𝒖𝒕 = (out
𝑶𝟏 O1- = out O1 – (1-out O1)
𝝏𝒐𝒖𝒕
target = 0.7513 – (1- 0.7513)
𝑶𝟏 O1) = 0.5026
𝝏𝑬 𝑶𝟏
𝝏 𝒏𝒆𝒕 = 0.7413 * 0.5026
𝑶𝟏 = 0.37257738
𝝏𝒏𝒆𝒕 = on total of O1 from h1 => W5
𝑶𝟏
𝝏 𝒐𝒖𝒕
= 0.4
𝒉𝟏
MALLA REDDY COLLEGE OF ENGINEERING
Working of Backpropagation Algorithm with an
example
part 3:
calculate Backward propagation error
(hidden layer to input layer )
W1,W2,W3,W4 W1(0.15) W5(0.40) 0.01
0.05 h1 O1
𝝏𝑬 𝑶𝟏 𝝏𝑬 𝑶𝟏 𝝏𝒏𝒆𝒕 𝑶𝟏
x1
𝝏 𝒐𝒖𝒕 𝒉𝟏= 𝝏 𝒏𝒆𝒕 𝑶𝟏 𝝏 𝒐𝒖𝒕
* 𝑶𝟏
=0.37257738*0.4
𝝏𝑬 𝑶𝟐 𝝏𝑬 𝑶𝟐 𝝏𝒏𝒆𝒕 𝑶𝟐
𝝏 𝒐𝒖𝒕 𝒉𝟏 𝝏 𝒏𝒆𝒕 𝑶𝟐 𝝏 𝒐𝒖𝒕 𝒉𝟏
= * 0.99
x2 h2 O2
= -0.03809823 * 0.50 0.10
W4 (0.30) W8 (0.55)
𝝏𝑬𝒕𝒐𝒕
𝝏𝑬 𝑶𝟏 𝝏𝑬 𝑶𝟐
𝒂𝒍
= +
𝝏 𝒐𝒖𝒕 𝝏 𝒐𝒖𝒕 𝒉𝟏 𝝏 𝒐𝒖𝒕 𝒉𝟏
𝒉𝟏
= (0.37257738*0.4) + (-0.03809823 * 0.50 )
= 0.019049115+0.149030952
=0.168080067
0.99
x2 h2 O2
𝝏𝑬𝒕𝒐𝒕𝒂𝒍
0.10
Wm
Hn(x)
Xn
MALLA REDDY COLLEGE OF
ENGINEERING
The hidden layer use a non – linear radial basis function as the activation function.
Which converts the input parameter into high dimension space which is then fed
into the network to linearly separate the problem.
H1(x)
X1
W1
X2 H2(x)
W2 yn Y
Wm
Hn(x)
Xn
MALLA REDDY COLLEGE OF
ENGINEERING
This cab be used in 1. Classification 2. interpolation 3. function approximation
4. Time series prediction 5. System control
H1(x)
X1
W1
X2 H2(x)
W2 yn Y
Wm
Hn(x)
Xn
MALLA REDDY COLLEGE OF
ENGINEERING
•The Gaussian Radial basis function which monotonically
decrease with distance from the centre.
−(𝑥−𝑟)2
𝐻𝑥 = 𝑒 𝑟2 where x = input
R = radius
C = centre
A multiquadratic RBF which monotonically increase with distance from the centre
𝑟2+
(𝑥−𝑐)2
H(x) =
MALLA REDDY COLLEGE OF
ENGINEERING
•Algorithm for RBF
where input : input vector : x1,x2…….xn
Output : yn
Assign random weights for every connection from the hidden layer to the output layer in the
network in the range [-1 to +1]
Forward phase :
Calculate input and output in the input layer (input layer as direct transfer function)
where the output of the nodes equals the input
Input at node I in the Input layer is Ii=xi where xi is the input received at node I
Output at node I “Oi” in the input layer is Oi = Ii
MALLA REDDY COLLEGE OF
ENGINEERING
• Step2: for each node j in the hidden layer, find the center (c) and the variance
r define hidden layer neurons with gaussian RB
−(𝑥𝑖−𝐶𝑗)2
𝐻𝑖𝑥 = 𝑒 𝑟2 compute (x-cj) applying Euclidian distance measure between x and cj
Step 3 : for each node k in the output layer, compute linear weighted sum of the output of each
neuron k from the hidden layer neurons j.
𝑓𝑘 𝑥 = ∑𝑚 𝑗= 𝑊𝑖𝑗 𝐻𝑗(x) where Wij = weight in the link from the hidden layer neuron j to
the output1layer
H(x) is the output of a hidden layer neuron j for an input vector x
Backward phase :
1. Train the hidden layer using Back Propagation
2. update the weights between the hidden layer and output layer
MALLA REDDY COLLEGE OF
ENGINEERING
RBF Networks are conceptually similar to K-Nearest Neighbor (k-NN) models, though their implementation is distinct. The
fundamental idea is that an item’s predicted target value is influenced by nearby items with similar predictor variable
values. Here’s how RBF Networks operate:
1. Input Vector: The network receives an n-dimensional input vector that needs classification or regression.
2. RBF Neurons: Each neuron in the hidden layer represents a prototype vector from the training set. The network
computes the Euclidean distance between the input vector and each neuron’s center.
3. Activation Function: The Euclidean distance is transformed using a Radial Basis Function (typically a Gaussian function) to
compute the
neuron’s activation value. This value decreases exponentially as the distance increases.
4. Output Nodes: Each output node calculates a score based on a weighted sum of the activation values from all RBF
neurons. For classification, the category with the highest score is chosen.
The Curse of Dimensionality in Machine Learning arises when working with high-dimensional data, leading to increased computational
complexity, overfitting, and spurious correlations. Techniques like dimensionality reduction, feature selection, and careful
model design are essential for mitigating its effects and improving algorithm performance. Navigating this challenge is
crucial for unlocking the potential of high- dimensional datasets and ensuring robust machine-learning solutions.
Polynomial Interpolation
Polynomial interpolation is a method of estimating values between known data points by fitting a polynomial
function to the data. The goal is to find a polynomial that passes through all the given points.
This method is useful for approximating functions that may not have a simple analytical form. One common
approach to polynomial interpolation is to use the Lagrange polynomial or Newton’s divided differences method
to construct the interpolating polynomial.
Implementation
This article demonstrates polynomial interpolation using the interp1d function from SciPy.
It begins by generating sample data representing points along a sine curve. The interp1d function is then applied
with a cubic spline interpolation method to approximate the curve between the data points.
Finally, the original data points and the interpolated curve are visualized using matplotlib, showcasing the
effectiveness of polynomial interpolation in approximating the underlying function from sparse data points.
MALLA REDDY COLLEGE OF
ENGINEERING
import numpy as np
from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
The goal of the SVM algorithm is to create the best line or decision boundary that can segregate n-dimensional space into classes so that we can easily put
the new data point in the correct category in the future. This best decision boundary is called a hyperplane.
SVM chooses the extreme points/vectors that help in creating the hyperplane. These extreme cases are
called as support vectors, and hence algorithm is termed as Support Vector Machine. Consider the below
diagram in which there are two different categories that are classified using a decision boundary or hyperplane:
Types of SVM
SVM can be of two types:
o Linear SVM: Linear SVM is used for linearly separable data, which means if a dataset can be classified into two classes by using
a single straight line, then such data is termed as linearly separable data, and classifier is used called as Linear SVM
classifier.
o Non-linear SVM: Non-Linear SVM is used for non-linearly separated data, which means if a dataset cannot
be classified by using a straight line, then such data is termed as non-linear data and classifier used is called
as Non-linear SVM classifier.
MALLA REDDY COLLEGE OF
ENGINEERING
Linear SVM:
The working of the SVM algorithm can be understood by using an example. Suppose we have a dataset that has two tags (green and blue), and the
has two features x1 and x2. We want a classifier that can classify the pair(x1, x2) of coordinates in either green or blue. Consider the below image:
So as it is 2-d space so by just using a straight line, we can easily separate these two classes. But there can be
multiple lines that can separate these classes. Consider the below image:
dataset
the SVM algorithm helps to find the best line or decision boundary; this best boundary or region is called as a hyperplane. SVM algorithm finds the
closest point of the lines from both the classes. These points are called support vectors. The distance between the vectors and the hyperplane is called
as margin. And the goal of SVM is to maximize this margin.
MALLA REDDY COLLEGE OF
ENGINEERING
The hyperplane with maximum margin is called the optimal hyperplane.
Non-Linear SVM:
If data is linearly arranged, then we can separate it by using a straight line, but for non-linear data, we
cannot draw a single straight line. Consider the below image:
So to separate these data points, we need to add one more dimension. For linear data, we have used
two dimensions x and y, so for non-linear data, we will add a third dimension z. It can be calculated as: z= x2 +
y2 By adding the third dimension, the sample space will become as below image:
MALLA REDDY COLLEGE OF
ENGINEERING
So now, SVM will divide the datasets into classes in the following way. Consider the below
image:
Since we are in 3-d Space, hence it is looking like a plane parallel to the x-axis. If we convert it in 2d with z=1, then it will
space become as: