ml 6th (2)
ml 6th (2)
_________
Machine Learning (SPPU-Sem5-IT)
• The brain analyzes all patterns of signals sent, and from • The lnfonnalion processing system is comp,1Se~J of a
that information ii interprets the type of information large number of highly mterconnected pro..:essmg
received. There are different types of Biological ele~ents (nellrons) which ",wks togetht>r to solv;
specific problems.
neurons.
When the neurons are classified by the processes they
• In . Biological Sys1t•m learning prO\.'ess involves
carry out they are classified a1> unipolar neuron~. tulJustmonts to lhc S} naptic connections th .
at exist
-
h etwccn lhl· m•urnns. in thr s.une
bipolar neurons and mult1polar neurons. manner learning is
cumcd 0111 111 ANN. ~
UNI'
~ _ _ _ _ _ V]
CNew Syllabus w.e.f academic year 21-22) (PS-46) ~ Tech•Neo Publications.. A SACHIN SHAH Venture ■
~~~~
1tl 'f •
Machine Leaming (SPPU-SemS-IT)
(Introduction to Artificial Neural Network) ...
• ANN can be used in many Apphnil
mn~. P.illcrn
Page no 6-4
extraction and detectio n of trend, 1, ,1 kdm • Till' outp ut of the ahove model is~i)'en
as,
us pwrc.ss
V- 1 ·l r 11elI = r,wIJ.. '1' XJ-> T
for humans and ol hn l'l'llll'\llc1 tcchniqm
networks. with llll'i i H'm111 l,.ahlc nh1h
•:.. Nl·
W<T 2. 0~T Using this values the Aa"ID gate is represented as.
I.
Now select lhe values of W and T such that the abo\'e W 1 =05
X1
conditions gets satisfied ( T= 0.8 X
One of the possible ulues are T=O. W= - I X2
W2 =03
Using this values the NOT gate is represented as,
~ 6.4 DIFFERENCE BE1WEEN
X
~ y BIOLOGICAL NEURON AND
ARTIFICIAL NEURON
Ex. 6.3.2 : Simulation of AND gate using McCulloch . Pius
Model The truth table of the AND gate is as follows Sr. Points of Biological NN Artiflclal NN
No. Difference
Input Output 14
I. Processing 10 synapses 108 transistors
X1 Xi y elements
0 0 0 2. Speed Slow Fast
0 1 0 3. Processing Parallel Execution One by one
I 0 0 4. Size and Less More,
I I Complexity difficu lt to
I
of implement
We assume the weight vector as W I for X1 and W2 for X2 operation complex
For the first row, we may wnte nel values as operation
CW1X X1) + CW2X Xi) = (W1 XO)+ (W2x 0) = 0 5. Faull Exist Doesn't exist
Tolerance
According to the McCulloch - Pitts model if the output
6. Storage If new data is added Erased
,s 0 then net value must be less than threshold O< T.
old is not era~ed
For the second row, we may write net values as 7. Control Every neuron acts CPU
(W1xX 1) + (W2 x Xi)= (W 1x 0) + (W2 x I) = Wz Mechanism independently
According to the McCu lloch - Pitts model if the output
~ 6.5 ACTIVATION FUNCTIONS AND
is 0 then net value must be Jess than threshold W2< T.
TYPES
For the third row. we may wnte net values as
(WI x X1) + CW2 x X2) =(WI X 1) + (W2 :,< 0) = W1 ~ 6.5.1 Activation Functions In a Neural
According to the McCulloch • Pitts model if the output
Network
is 0 then net value must be less than threshold W1< T • Artific ial neural networks are important part of many
structu res that are helping revolutionize the world
For the fourth row, we may write net values as
around us.
iW1 XX1) + CW2x Xv = CW1 X 1) + (\V2X I)= w ,+ W:
<New Syllabus w.e.f academ ic year 21·22) (PS-46) [i1 Tech•Neo Publications_.A SACH1N SHAH \len\\Q
r
Machine Learning (SPPu s
· emS-li)
• Now Jet us see, how do artificial (Introduction to Arlif!clal Neural Network) ... Page no 6-s
the required perfor neural networks shows
problems A d hmance to find solll!ions !o real-world • Activation functions help neural neLworks
10
ma};
. · n l e answer for this is an Ac1ivmion
Functions. sense of complicated, high dimensional, and non-line;
Big 011111 ~ct~ 1ha1 huve an intricate archi tecture_ !he
• Anificial neural n t k . .
c wor s uses 11ctiv1111011 functloi1s 10 conlnin multiple hidden Juyers in be1ween the input on:
compute many comple~ cnlculmmns 111 tl1c hlclch.i, 1 OU!Jllll Juyer.
layers and then forwurd the rcsul1 to the unlplH luycr.
The main aim of m:h\'(ttlon l'llnctinns is 10 introduce 'a. 6.5.J Sort and Hard limiting Function TYJts
non-linenr properties in the ncurnl network. ;-----------------------------
UQ, Write a note on Sigmoid, Tanh, Retu
..
• Acth•otion ftinctions convert the linear input signals of
1
nre differentiable. This property helps 1hem function I Ellplain slgmold function. •·
during the backprop.'lgntion of the neural networks. l- -- - - - - • - • - -- - - - -- - - --- ------.J'
• Activation function f(x) is used 10 give ompu1 of a \" !The hard limiting activation functions forces a neuron
neuron in tenns of a local field x or net, The various to output I if its net input reaches a threshold.
activation functions are discussed in the coming otherwise ii outputs O•.This allows a neuron t ~ a
section. decision or classification.
• It can say yes or no. This kind of neuron is often
'a. 6.5.2 Need for Non-linearity trained with the pe~_:_p~earning i:ule. Exactly
',--------------- ---------------
UQ. Explain why we use non-linearity function?
reverse of hard limit ls the soft limitine activation
functions.
' ,.
(SPPU - Dec 18, 4 Marks)
~------------------------
•
-----J
If we do not use activation functions then the output
Linear
(New Syllabus w.e.f academic year 21-22) (PS-46) Ii] Tech-Neo Publkat1ons.. A SACHIN SHAH venll,l'f
Machme leant.'lg (SPPU-Sem5-lT}
(lntroauetion to Art15aa Ne~•al Ne:W00<J...Page no (6-n
/ " Rectified Linear Unit (ReLU)
•
Outp:::= ~ (0, Oct = net
ifoet~0
=max <O. net. =o 11 Det <0
• Rect;f..eo lmear
• • - lll.!!l.JS 0De of the Ill_QSt fr~U\" n5td
0 n
--
• This function is used in Percepaon's s. to create
gradient-descent metiiods.
neurons that make classification decisions.
• The ReLU function perfonns a lhreshold operation on
each input element where all values Jess than zero are 5, Saturating linear
set 10 zero.
Ou1pu1 =O if oe1 < 0
~- ~ d llmlt / Unipolar binary = net ifOSne1< I
Output =O Ifoet<O = I if net::! I
= I ifnc120
a
3
r +1 '
! O +1 n
tr 0 n
[] -1
-1--·
a = satlin(n)
a = hardlim(n) satlln Transfer Function
Output = - I if net<· I
• The hard-limit transfer function shown above hmll\ the
output of the neuron to either 0. if the net input = net if -1 S net < I
argument n is less than 0, or I, if o is greater than or =I if net 2 I
equal to 0. a
• This function is used m Perceptroo·s. 10 create neurons +1
that make classification decisions.
UNIT
------------------==---a-=sa_ u_1n(-s)------ kiY
(New Syllabus w.e.f academic year 21-22) (PS-46) ~ Tech-Neo Publications .A SACHIN SHAH Venture
Machine Leaming (SPPU-SemS-IT)
• The symbol in the square (lnlroduclion to Arllflolal Neural Network) ... Page no 6-a
function graph h . to th c nght of each trnnsfcr
,. f
5
O\\n above r('p1cscn1s lhc a\s1>nnI •d
~ 6.6 NEURAL NETWORK ARCHITECJull
lrans,er unchon. 1
.,
r ts,
Y
011tplll \'C,,'l<'r,
= IY 1, Y2, Y1........
a • tan&lg(n)
T■n••lgmo1d Transfer Function
(New Syllabus w.e f 1cadem1c year 21·22) (PS-46) Ii} Tech Neo Pubhcations.. A SACHIN SHAH Ventult
- , .. ,
Now we will c11lcu\1nc thr fin ;1l ut1lpu1 rm !he 11,/veu 4.83
nc1i\'Dlion f1111clion~
0 ) -"-""--{HHc1A. 5.73
,. Hurd lhnlt
Ott!put •O ir, UCI <0
., if, net 2:: 0
Mcnee, Y • 0
j Output =-
•I
I if.ne!<O
if,nct2::0
@ Soln. : PirMl we wi!I calculate net input and output of
hidden nodes,
l-ll (nel) .. (4.8)X0)+(-4.IJ3X l)-2.82=-7.65
Hence, Y =- I _,
,. Linear
Hl (ou1pu1) "' 4.758 X JO
H2(nctJ "' (-4.63x0)+(4.6x 1)-2.74= 1.86
Output = net
H2{(1\l!putl = 0.865
Hence, Y = -0.8
Now we will calculate net input and output of output
4. Sa1urating linear node,
Output • 0
= net
if,net<O
if,0:Snet< I
= (4.758x 10
= 2.167
-· x 5.73)+(0.865x5.83)-2.86
Hence, Y • 0
»I 6.8 PERCEPTRON
5. Symmetrical saturating linear
--------------------------------
: UQ. Explain Perceptron training algorithm for linear :
Output = - I if,net<-1
= net if.-1:Snet<l
:
---- -- - -- - -- - - - - - -- - - - - - - - - - - - - .
classification, :
Hence, Y=0.1418
7. Bipolar continuous b
2 Fig. 6.8.1 : Pcrceprron Architecture
Output = (I+ exp(. 1.. x net)) UNl
-----'H"''c"""e"c,• Y = 0. 71
(New Syllabus w.e.f academic year 21-22) (PS-46) [i1 Tech-Neo Publications
~I
A SACHIN SHAH Venture
Machine Leaming (SPPU-SemS-IT)
(Introduction to Artificial Neural Network) ... Page no (&-1
. Output of the neuron is 1/0 or 1/- l. thus each neuron 2
~ e network divides the input spa.:e into two regions. This
th Ill 6. 9 PERCEPTRON LEARNING
ALGORITHM
is useful to determine the boundary between U1ese regions.
Let's see the example for tl1is ,--- ------ -- --- -- - ----- ----- ---,
; UQ. Ekplaln Perceptron training algorithm for linear :
P1 W11 1
classification. 1 IJ.i44 6•/1 I
1 _ _ -- -- - -- - -- -- - - - -- -- -- - -- ---- !
X1 wil I th neuron
W12
x2---::J r - -, -o
b x,
Output of the above network is given by, ti Wj
0 = hardlim(W 11 xP 1 +W12XP2+b)
X d
Input vector for which the net input is zero determines
the decision boundary
W11XP1+ W12XP2+b :0 C
Let's take the valueofW 11 =W 12 : I llildb:- J and Fig. 6.9.I; Perceptron Learning rule
substitute this values in the above equation we wil l gel
Percepr.ron Learning is a supervised type of !earning as
Pr+P2-l=O
the desiied res_ppnse is present.JI~ is applicable on!~
To draw the decision boundary we need to find the Binary types of neurons (activation functions). Learning
intercepting points of P1 and P2 axes signal is the difference between the actual output and
P1+P2-l = 0 desired output of neuron and it is used to update the weight.
Substitute P1"'0 then we will get P2 "' l i.e. (0, !) Learning signal, r :@-@ ,L.t S11tJ)..
Substitute P2"' 0 then we will get P 1= I Le. (J ,Q) Where o; is the oucpit'-tY lhe
0
Then.
Decision boundary is always orthogonal to the weight ti.W1J "'Cxfd1-oj]xXj
vector and it always points 1owards the region where neuron =Cx[-1-IJxXJ
output is ! .
= -2C)S
Hence, AWy "" :t2 C X J
~ -I ~
o 1 = f(net 1) = l as d 1 .t o 1
• Step 2 : When X2 is applied
W2 = w , +Cx(d1-otJXX1
~
As we know t1W1 =± 2 x C x X3 and d3 =- I. 1-e
= r =:-1 + 1 ))l- -
(1 - (- I 7J = r - ; ]
consider the negative ~ign
2
L -1 L o'
In lhc problem it is given thal we have to repeat the
trainmg Until lwo correct responses are achieved, so we will
again apply x 1•
•~, = w;xX,=H -3
04 = f(ne14) =l
oi[ -~]=3
As d 2 = o4 ,weight updation is not required
-1
AW, = 2xcxx,{ ~f]
Ws = W4
Thus we have obtained the correct response in a row
two times.
w, = W,-AW,=[ ~]
Ex. 6.9.3 : A Single neuron nelwork using f(net) = sgn(nel) • Step3
bas been trained using the pairs of Xi, ~ as follows. Find
Initial weight vector. W2 = W 1 +t.W 1
)Jx,{ ~n
The above equation can be written as, W 1 = W - fl W
2 1
w,=U J.x,{
As we know t.W1 = ± 2 x C x X 1 and d 1 = - I we
consider the negative sign
bs = b4+e=-l+l=O
=Hardlim([ ~] [OOJ+(-3)):Hardlim(-3)=0
We have to repeat Lhe iterations until all input vec1or-s
Ex. 6.9.5 : Solve the following classification problem with are correctly classified (i.e. error = 0 for all the input
Perceptron learning rule. Apply each input vector in order vectors)
for as many repetitions as it takes lo ensure that the problem Iteration 2
is sol\'ed. Draw a graph of t11e problem only ofter you found • Step 5 : When Pa L~ applied
a solulion. ] 05=hardlim(W,xP 1+b 5)=hnrdhm(-8) =0
1
W =fOOJ,b =0.P 1=[ : ] t 1 =0,P2= [ _ t2=l, Enor,e=ti-os=0-0=0 UNf
1 1 2
-----------;::;;-----1
(New Syllabus w.e.t academic year 21-22) (P5"46)
~ Tech-Nee Publication~ ..A $ACHIN SHAH Venture
~3~!ne learning (SPPU-Sem5-IT) (Introduction to Artificial Neural Network) .•. Page no (6-16)
S ·:,..:e the error is 0, weight and bias updation 1s nol W11 = Wio
requrred. b11 = bio
W6 = W5 Now for P1 also we are getting the error. e = 0.(n this
~
1 +e
Object detecuon etc. are not linearly separable. • Weight Increment, AWij = C x (di-Oi] )( £' (neti) )( Xj
• TbcSC problems will require non-linear boundari~. We where C is a constant and Xis input & j = l to n
can solve this problem by using more complex network WMw=WoJd+t.Wij
with more than one perceptron.
Ex. 6.11.1 : Prove the following
• In perceptron network learns by updating the weights
(a) For unipolar continuous, f'(ne1i) =0 (I - 0)
until prediction is satisfactory. 0
(b) For bipolar continuous. f' (neti) = V2 (I - o·)
• Here we need multiple layers and all that layers should
be fully connected to each other, so when 1he input (a) For unipolar continuous, f'(netl)= 0 (1-0)
signal propagates through the network in a forward • As we know for unipolar continuous function
direction, on a layer-by-layer basis these neural f(nel) = 1/(J+e·x)
networks commonly referred to as M11l1ilayer • We diffcren1iate the above equation with respect to x
Perceptro11. f'(net) = ( (l+ e-~) d/dx (I)- I d/dx (1 + e-x)) / (I+ e-x)i
-x -x 2
=e/(l+e)
'a 6.1 f .2 Leaming Parameters- Wel1ht and
• We may write th!.'; abo,·e equation as
Blas
= (l+e-x-l)/{l+e·x)2
Jn above sections we have seen how to update weight = ((l+e-x)/(l+e-x}2)-{l/(l+e-x.)°½
and bias in case of single perceptron. Now we will see bow = (l/(l+e•x))-(l/(1+e-x)2)
IO update weight and bias for multilayer perceptron. To 0
= f(net) - f(net) w
output layer • We cnn write (dk - Ok) X f (nelk) = dok which is the
error present in the output layer and d(ne!Jt)/dY, a\ Wk,
• The above •~ a simplified diagram for the muh11l1yer which is the weight vector present between the hidden
perceptron network \\ hich represents the three Inyo, and output layer.
input(t). h1ddenO) and output(k).
• Thus we will get
Layer i (input) Layer j (hidden) Layer k (output) dE/d Y1 = - :[d0 kWkj
z y 0 • By substituling this in Equation (4) we will gel
• We may write the term dE/dVj, as The steps followed during learning are :
dF/dVji :: de/ dneljX dne~/ dVjl ... (6.11.2) 1. First the input is applied to the input layer to calculate
_ (dE/dnet:_;) is che error signal for hidden layer which Lhe output of !he hldden layer. The output of !he hidden
can be represented as dY, layer becomes the input of the next layer. Finally. the
dnetj/dVj, represent the input applied at the input layer output of the output layer is calculated.
•
i.e., Zi 2. The desired and the actual output at the output layer are
By substituting this values in Equation (6. I l.2) and
• compared with each other and an error sign:il is
Equation (6.11.1) we will gel generated.
... (6.11.3)
6 Vji = TJ x dYj X Zi
3. The error of Lhe output layer is back propagated 10 the
• As we are saying that dYJ = - dE/dneti
hidden layer so that the weights connected in each layer
• We can write this term as of the network can be properly adjusted.
. .. (6.11.4)
dYj = - dE/dYj X dY/dnel;
.
unseen pattems are co~tJy clus fi r to check if 1hc
s, 1ed or not.
,
4,
he ca~y. Increase number of hidden layers. performance
nmy get linprovcd .
learning con•tant
Lc:nrning coMl:mt Hhould be voried when the learning
r111e lncre11~cs speed of ,raining increases.lO-l to 10
values ure proved 10 be successful for learning rate.
Leaming rate has to be increased for some training
cycle.~ and 1hen it hus to be reduced.
c.k:~1110 urrurdQ, <N
<10 • (do - o,r r, ,,.'- i
lfYsw1' ·ao•v-
-...
BIIQln
l rllltj"II
5, Momentum
Momentum gives push to training Momentum is lhe
previous weight adjusllllent.
AdiUlt weights of 0\J!pl,l layo, at
.O.W(t) = -T\ AI!(!}+ a: 6W(t- I)
w .. w .,i ·oo·v'
where a: values varies from 0.1 to 0.8
~ we~~"' af ~ layer u 6. Steepness or activation function
V"'V•'l·crt·i
It is advisable to keep).. at a standard value of I.choice
E ~-
. a
,.
E< ' - n IN li1lltllllg ..i
Ex. 6.11.2 : Classify the input of following network using
~
unipolar continuous function and EBPT A.
v,1 = =
V11 +1) xd Y1 xz , 2 + 0.3
x (-0 .02 ) x0 .6 I
I
(SP PU · Jun e 18, 7 Ma I
I
I
learning.
= 2.0 036 • UQ. Write a no te on Deep
I 16, 8 Ma rks )
V12 = Y1 2+T JX dY1X Zz
= I +0 .3x (-0 .02 )x0 = I I (SP PU • De c. 16, Jun e
f
Ch ap ter En ds...
aaa
,_
r- )