0% found this document useful (0 votes)
22 views135 pages

DL UNIT 1 To UNIT 3 Lecture Notes

Uploaded by

Shahul Shariff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views135 pages

DL UNIT 1 To UNIT 3 Lecture Notes

Uploaded by

Shahul Shariff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 135

lO M oAR cPSD |270 42294

lO Mo ARcP SD| 2704 2294

Pragati Engineering College (A), Surampalem

Department of Computer Science & Engineering

DEEP LEARNING

LECTURE NOTES

R20
lO M oAR cPSD |270 42294

U n it –
1
Fundamentals of Deep Learning: A rtificia l In te llig e n c e , H is to ry
o f M a c h in e le a rn in g : P ro b a b ilis tic M o d e lin g , E a rly N e u ra l
N e tw o rk s , K e rn e l M e th o d s , D e c is io n T re e s , R a n d o m fo re s ts
a n d G ra d ie n t B o o s tin g M a c h in e s , F u n d a m e n ta ls o f M a c h in e
L e a rn in g : F o u r B ra n c h e s o f M a c h in e L e a rn in g , E v a lu a tin g
M a c h in e le a rn in g M o d e ls , O ve rfittin g a n d U n d e rfittin g .

Fundamentals of Deep Learning


Artificial Intelligence (AI)
A r tific ia l In te llig e n c e ( A I) re fe rs to th e d e ve lo p m e n t o f c o m p u te r s y s te m s o r
m a c hin e s th a t c a n p e rfo rm ta s k s th a t w o u ld typ ic a lly r e q u ire h u m a n in te llig e n c e . A I
a im s to r e p lic a te o r s im u la te h u m a n c o g n itiv e a b ilitie s , s u c h a s p e rc e p tio n ,
re a s o nin g , le a rn in g , p ro b le m - s o lvin g , a nd d e c is io n - m a k in g .

A rtific ia l in te llig e n c e (A I) p la y s a s ig n ific a n t r o le in d e e p le a rn in g . D e e p lea r nin g


a lg o rith m s ar e a s p e c ific s u b s e t o f A I te c h niq u e s th a t u s e a rtif ic ial n e u ra l n e tw o r k s to
m im ic h um an b ra in fu n c tio n a n d le a rn f ro m d a ta . H e re 's h o w A I is in c o rp o ra te d in to
d e ep le a rn in g :

1. L e a rn in g a n d A d a p ta tio n : D e e p lea r nin g m o d e ls u tiliz e A I te c h n iq u es to le a rn


a n d a d a p t fr o m la rg e d a tas e ts . T h e y le a rn to re c o g n iz e p a tte rn s , m a k e p re d ic tio n s ,
o r c la s s if y d a ta b y a d ju s tin g th e ir in te rn a l p a ra m e te rs b a s e d o n fe e d b ac k re c e ive d
d ur in g the tra in in g p ro c e s s .

2. F e a tu r e E x tra c tio n : A I m e th o d s a re u s e d to a uto m a tic a lly e x tr ac t re le v a nt


lO M oAR cPSD |270 42294

fe a tu re s o r r e p re s e n ta tio n s fro m ra w d a ta . In s te a d o f m a n ua lly d e fin in g fe a tu re s ,


d ee p le ar n in g m o d e ls c a n lea r n h ie ra rc h ic a l re p re s e nta tio n s th a t c ap tu re im p o r ta n t
c ha r ac te ris tic s o f th e in p u t d a ta . A I a lg o r ith m s , s u c h a s c o n vo lu tio n a l n e u ra l
n e tw o rk s (C N N s ), a re c o m m o n ly e m p lo ye d to e x tra c tfe a tu re s f ro m im a g e s , a u d io ,
o r te x t.

3. N a tu ra l L an g u a g e P ro c es s in g ( N L P ): N L P is a fie ld o f A I th a t d e a ls w ith th e
in ter a c tio n b e tw e e n c o m p u te r s an d h u m a n la n g u a g e . D e e p lea r nin g te c h niq u e s ,
s u c h a s re c u rre n t n e u ra ln e tw o rk s (R N N s ) a n d tra n s fo rm e r m o d e ls , a re u s e d in
N L P ta s k s lik e m ac h in e tr an s la tio n , s e n tim e n t an a ly s is , la n g u a g e g e n e ra tio n ,
a n d q u e s tio n -a n s w e rin g s ys te m s .

4. C o m p u te r V is io n : D e ep le a rn in g h a s re vo lutio n ize d c o m p u te r v is io n ta s k s , s u c h
a s im a g e c la s s ific atio n , o b je c t d e te c tio n , a n d im ag e s e g m e n ta tio n . A I a lg o r ith m s ,
in c lud in g C N N s a n d d e e p c o n v o lu tio n a l g e n e ra tiv e a d ve rs a ria l n e tw o r k s (D C G A N s ),
e n a b le m a c h in e s to p e rc e ive a n d u n d e r s ta n d v is u a l d a ta w ith re m a rk a b le a c c u ra c y .

5. R e in fo rc e m e n t L e a rn in g : R e inf o rc e m e nt le a rn in g is a b ra n c h o f A I c o n c e r ne d
w ith tra in in g a g e n ts to m a k e d e c is io n s in a n en v iro n m e n t to m a x im ize r ew a rd s .
D e e p re in fo r c e m e n t le a rn in g
lO M oAR cPSD |270 42294

c o m b in e s d e e p le a rn in g a nd re in fo rc e m e n t le a rn in g te c h n iq ue s , e n a b lin g a g e n ts to
le a rn d ire c tly fro m ra w s e n s o r y inp u t a n d a c h ie v e im p re s s ive p e rfo rm a n c e in
c o m p le x ta s ks , s u c h a s g am e p la yin g a n d ro b o tic s .

6. A u to n o m o u s S y s te m s : D e e p le a rn in g , a lo n g w ith A I p rin c ip le s , is a k e y
c o m p o n e n t in th e d e v e lo p m e n t o f a u to n o m o us s ys te m s . T h e s e s y s te m s , s u c h a s
s e lf- d r iving c ar s a n d a u to n o m o u s d r o n e s , re ly o n d e e p le a rn in g alg o rith m s to
p er c e iv e th e e n vir o n m e n t, in te rp re t s e n s o r d a ta , a nd m ak e r ea l- tim e d e c is io n s .

O v e ra ll, a rtific ia l in te llig e n c e p ro v id e s th e fo u n d a tio n a n d to o ls fo r d e e p


le a rn in g a lg o rith m s to lea r n, a d ap t, a n d p e r fo rm c o m p le x tas k s a c ro s s v a rio u s
d o m a in s , ra n g ing fro m c o m p ute r vis io n to n a tu r al la n g u a g e u n d e rs ta n d in g .

History of Machine learning


T he h is to r y o f m a c hin e le ar n in g d a te s b a c k s e ve r al d e c a d es a n d h a s u n d er g o n e
s ig n ific a n t d e ve lo p m e nts o v e r tim e . H e re 's a b rie f o ve rv ie w o f th e k e y m ile s to n e s in
th e h is to ry o f m ac h in e le a rn in g :

1 . E a rly F o u n d a tio n s ( 19 5 0 s - 1 9 6 0 s ) :

- T h e fie ld o f m a c h in e le a rn in g e m e rg e d fro m th e in te rs e c tio n o f


c o m p ute r s c ie n c e a n d s ta tis tic s , w ith e a rly p io n e e rs in c lu d in g A la n T u ring a n d
A rth u r S a m u e l.

- In 1 9 5 0 , A la n T u rin g p ro p o s e d the " T ur in g T e s t" a s a w a y to m e a s u re a


m a c h in e 's a b ility to e x h ib it in te llig e n t b eh a v io r .

- In the 1 95 0 s, A rth u r S a m u e l d ev e lo p e d th e c o n c e p t o f m ac h in e le a rn in g b y
c re a tin g p ro g ra m s th a t c o u ld im p ro ve th e ir p e rfo rm a n c e over tim e th r o u g h
e x p er ie n c e , s p e c ific a lly in th e d o m a in o fg am e- p la yin g , s uc h a s c h ec k e rs .

2 . S ym b o lic A I a n d E x p e rt S y s te m s ( 19 6 0 s - 1 9 8 0 s ):

- D u rin g th is p e rio d , re s e a rc h e rs fo c us e d o n s y m b o lic A I a n d e x p e rt s ys te m s ,


w h ic h r e lie d o n ru le s a n d lo g ic a l re a s o n in g .

- M a c h in e le a rn in g to o k a b a c k s e a t a s ru le - b a s e d s ys te m s d o m in a te d th e fie ld ,
w ith p ro je c ts lik e D E N D R A L ( a s ys te m f o r m o le c u la r b io lo g y ) a n d M Y C IN ( a s y s te m
fo r d iag n o s in g b a c te ria lin fe c tio n s ) g a in in g a tte n tio n .

3 . C o n n e c tio n is m a n d N e u ra l N e tw o rk s ( 1 9 8 0 s - 1 9 9 0 s ) :

- In te re s t in n e u ra l n e tw o rk s a n d c o n n e c tio n is m re s u rg e d d u rin g th is p e rio d .

- B a c k p ro p ag a tio n , a w id e ly u s e d a lg o rith m fo r tra in in g n e u ra l n e tw o r k s , w a s


d ev e lo p e d in th e 19 8 0 s .
lO M oAR cPSD |270 42294

- T h e fie ld s a w ad va n c e m e nts in a re a s s u c h a s p a tte rn re c o g n itio n a n d


s p ee c h re c o g n itio n ,f u ele d b y n eu r al n etw o rk m o d e ls lik e th e M u lti- L a y e r
P e r c e p tro n ( M L P ) .
lO M oAR cPSD |270 42294

4 . S tatis tic a l L e a rn in g a n d D a ta - D r ive n A p p ro a c h e s ( 19 9 0 s -2 0 0 0 s ):

- R e s e a rc h e rs s ta rte d e m p h a s izin g s ta tis tic a l le a rn in g a n d d a ta- d riv e n ap p ro a c h e s .

- S u p p o r t V e c to r M a c h in e s ( S V M s ) g ain e d p o p u la r ity fo r c la s s ific a tio n ta s k s ,


o ffe rin g s tr o n g th e o re tic a l fo u n d a tio n s .

- T h e fie ld s a w th e e m e rg e n c e o f e n s e m b le m e th o d s , s uc h a s R a n d o m
F o re s ts a n d B o o s ting ,w h ic h c o m b in e d m u ltip le m o d e ls to im p ro ve p e r fo rm a n c e .

5 . B ig D a ta a n d D e e p L e a rn in g ( 2 0 1 0 s - p re s e n t):

- T h e ris e o f b ig d a ta, in c re a s e d c o m p u ta tio n a l p o w e r, a n d a d va n c e m e n ts


in d e e p le a rn in g m o d e ls re vo lu tio n iz e d th e fie ld .

- D e e p le a rn in g , s p e c if ic a lly C o n vo lu tio n a l N e u ra l N e tw o rk s ( C N N s ) a n d
R e c u rr en t N e u ra lN e tw o r k s (R N N s ), a c h ie ve d re m a rk a b le s u c c e s s in c o m p u te r
v is io n, s p e e c h re c o g n itio n , an d n a tu ra l la n g u a g e p ro c e s s in g .

- D e e p le a rn in g fra m e w o r k s lik e T e n s o rF lo w a n d P y T o rc h g a in e d
w id e s p re a d a d o p tio n ,m a k in g it e a s ie r fo r re s e a rc h e rs a n d p r a c titio n e rs to
b uild a n d tr a in d e e p ne u ra l n e tw o r k s .

T o d a y, m a c h in e le a rn in g is a ra p id ly e v o lvin g fie ld th a t c o n tin u e s to p us h


b o u n d a ries in a re a s s uc h a s re in fo rc e m e n t le a rn in g , g e ne r ative m o d e ls , a n d e x p la in
a b ility. It h a s b e c o m e a n in te g ra l p a rt o f nu m e r o u s a p p lic a tio n s , in c lu d in g
re c o m m e n d a tio n s y s te m s , fra u d d e te c tio n , au to n o m o u s ve h ic le s , a nd p e rs o n a lize d
m e d ic ine , a m o n g m a n y o the r s .

Probabilistic Modeling:
P r o b a b ilis tic m o d e lin g is a n a p p ro a c h to m o d e lin g a n d a n a ly zin g d a ta th a t
in c o rp o ra te s u nc e rta in ty a n d p ro b a b ility th e o ry . It a llo w s u s to re a s o n a n d m a k e
p re d ic tio n s in s itu a tio n s w h e re th e re is in he r en t va ria b ility o r n o is e in th e d a ta . In
p ro b a b ilis tic m o d e lin g , w e re p re s e n t u n c er ta in q u a n titie s a s p ro b a b ility d is tr ib u tio n s
a n d u s e s ta tis tic a l in fe re n c e te c h n iq u e s to le a rn a nd m a k e in fe r en c e s fro m th e
a v ailab le d a ta .

H e re a re s o m e k e y a s p e c ts a n d a p p lic a tio ns o f p r o b a b ilis tic m o d e lin g :

1. P r o b a b ility D is trib utio n s : In p ro b ab ilis tic m o d e lin g , w e a s s ig n p ro b a b ility


d is trib u tio n s to u n c e rta in v a ria b le s . T h e s e d is trib u tio n s d e s c rib e th e lik e lih o o d o f
d iffe re n t v a lu e s th e v a ria b le s c a n ta k e . C o m m o n ly u s e d p ro b ab ility d is trib u tio n s
in c lud e th e G a u s s ia n ( n o rm a l) d is trib u tio n, B er n o u lli d is trib u tio n, P o is s o n
d is trib u tio n , an d m o r e .
lO M oAR cPSD |270 42294

2. B a ye s ia n In fe re n c e : B a y e s ia n in f er e nc e is a fu n d a m e n ta l a p p ro a c h in
p ro b a b ilis tic m o d e lin g th a t a llo w s u s to u p d a te o u r b e lie fs a b o u t u n c e rta in va ria b le s
b as e d o n o b s e rv e d d a ta . It c o m b in e s p rio r k n o w le d g e o r b e lie fs (e x p r e s s ed a s p rio r
d is trib u tio n s ) w ith o b s er ve d d a ta to o b ta in p o s te rio r d is trib utio n s , w h ic h re p re s e n t
o ur u p d ate d b e lie fs .

3. G e n er a tiv e M o d els : P ro b a b ilis tic m o d e lin g e n a b le s th e c o n s tru c tio n o f


g en e ra tive m o d e ls , w h ic h c a n g e n e ra te n e w s a m p le s th a t re s e m b le the o b s e rv e d
d ata . G en e ra tive m o d e ls le a rn th e
lO M oAR cPSD |270 42294

u n d e rly in g p ro b a b ilis tic s tr u c tu re o f th e d a ta a n d c a n b e us e d fo r ta s k s s u c h a s


d ata g e n e ra tio n ,a n o m a ly d e te c tio n , a n d m is s in g d a ta im p u ta tio n.

4. B a ye s ia n N e tw o rk s : B a ye s ian n etw o rk s , a ls o k n o w n a s p ro b a b ilis tic g ra p hic a l


m o d e ls , a re g r ap h ic al r e p re s e n ta tio n s o f p ro b a b ilis tic d e p e n d e n c ies a m o n g
v a ria b le s . T h e y u s e d ire c te d ac yc lic g ra p h s to m o d el th e c o n d itio n al d e p e n d e n c ie s
a n d a llo w e ffic ie n t inf e re n c e a n d re a s o nin g ab o u t th e jo in t d is trib u tio n o f va ria b le s .

5. U n c e rta in ty Q u a n tif ic a tio n : P r o b a b ilis tic m o d e lin g p ro vid e s a n a tu ra l


fra m e w o r k fo r q u a n tif yin g a n d e x p re s s in g u n c e rta in ty. B y re p re s e ntin g u n c e rta in
v a ria b le s a s p ro b a b ility d is trib u tio n s , w e c a n e s tim a te c o n fid e n c e in te rva ls ,
c alc u la te p ro b a b ilitie s o f d iffe re n t o utc o m e s ,a n d a s s e s s the u n c e rta in ty a s s o c ia te d
w ith p re d ic tio n s o r d e c is io n s .

6. A p p lic a tio n s : P ro b a b ilis tic m o d e lin g fin d s a p p lic a tio n s in va rio u s fie ld s ,
in c lud in g fin a n c e , h e a lth c a r e, n a tu ra l la n g u a g e p ro c es s in g , c o m p u te r vis io n , a n d
m o re . It is u s e d fo r tas k s s u c h a s ris k a s s e s s m e n t, fra u d d e te c tio n ,
re c o m m e n d a tio n s y s te m s , s e n tim e n t a n aly s is , im a g e re c o g n itio n , a n d p re d ic tive
m o d e lin g .

N o ta b le p ro b a b ilis tic m o d e lin g te c h niq u e s in c lu d e B a y e s ia n re g re s s io n ,


H id d en M a r k o v M o d els ( H M M s ) , G a u s s ian P ro c e s s e s ( G P s ), a n d V a ria tio n a l
A uto e n c o d e rs ( V A E s ) . T h e s e te c h n iq u e s p r o vid e p o w e rfu l to o ls fo r m o d e lin g
c o m p le x s y s te m s a n d m a k in g p rinc ip le d in fe re n c e s in the p re s e n c e o f u n c er ta in ty .

Early Neural Networks:


E ar ly n e u ra l n e tw o rk s , a ls o k no w n a s th e f irs t- g en e ra tio n n e u ra l n e tw o rk s , e m e rg ed
in th e 1 9 4 0 s a n d 19 5 0 s . T h e s e e a rly m o d e ls la id th e fo u n d atio n fo r m o d e rn d e e p
le a rn in g a n d w e re th e p re c u rs o rs to th e m o re a d v a n c e d n e u ra l n e tw o rk s w e h a ve
to d a y . H e re a r e s o m e n o ta b le e a rly n e ur a l n e tw o rk s :

1. M c C u llo c h - P itts N e u ro n ( 19 4 3 ): P ro p o s e d b y W ar re n M c C u llo c h a n d W a lte r


P itts , th is m o d e lw a s a s im p lifie d a b s tr a c tio n o f a b io lo g ic al n e u ro n . It in tro d u c e d th e
c o n c e p t o f th re s h o ld lo g ic , w h e re in p u ts w e re s u m m e d a n d c o m p a re d to a
th re s h o ld to p ro d u c e a b in a ry o u tp u t. W h ile n o t a fu ll- fle d g e d ne u ra l ne tw o rk , it
p ro v id e d th e b a s is fo r fu tu re d e v e lo p m e n ts .

2. P e rc e p tr o n ( 19 5 7 ) : D e ve lo p e d b y F ra n k R o s en b latt, th e p er c e p tro n w a s o ne o f
th e e a rlie s t fo r m s o f a le a rn ing a lg o rith m fo r n e u ra l ne tw o rk s . It c o n s is te d o f a s ing le
la ye r o f inte rc o nn e c te d a rtif ic ial n e u ro n s ( M c C u llo c h - P itts n e u ro n s ) th a t c o u ld le a rn
to c la s s if y inp u ts into tw o c la s s e s . T h e p e rc e p tr o n le a rn in g ru le a d ju s te d th e
c o n n e c tio n w e ig h ts b a s e d o n e rr o rs m a d e d u rin g tr a in in g .
lO M oAR cPSD |270 42294

3. A d alin e ( 19 6 0 ) : A n a b b re via tio n fo r "A d a p tive L in ea r N e u ro n ," A d a lin e w a s


a ls o d e ve lo p e d b y F ra n k R o s en b latt. It w a s a n e x ten s io n o f th e p e rc e p tro n m o d e l,
in tro d u c in g th e u s e o f c o ntinu o us a c tiva tio n fu n c tio n s a n d re a l- v a lue d w e ig h ts .
A d a lin e c o u ld le a rn lin e a r re g re s s io n ta s k s a n d w a s a n e a rly e x am p le o f u s in g
g ra d ie n t d e s c e n t fo r w e ig ht a d ju s tm e n t.
lO M oAR cPSD |270 42294

4. M a d e lin e ( 1 9 6 0 s ) : S h o rt fo r "M ultip le A D A L IN E ," M a d e lin e w a s a n


a d v a n c e m e n t th a t in tr o d u c e d m u ltip le la ye rs o f A d a lin e n e u ro n s . It a llo w ed fo r th e
le a rn in g o f m o re c o m p le x d e c is io n b o u n d a ries a n d w a s o n e o f th e e a rlies t a tte m p ts
a t b u ild in g m u ltila ye r ne u ra l n e tw o rk s .

5. B a c k p ro p ag a tio n (1 9 7 0 s - 1 9 8 0 s ): A ltho u g h b a c k p r o p a g a tio n is n o w a


fu n d am en tal alg o rith m in d e e p le a rn in g , its d e ve lo p m e n t c a n b e tra c e d b a c k to th e
1 9 7 0 s . T h e c o re id e a b e h in d b a c k p ro p a g a tio n is to c o m p u te the g ra d ie n t o f th e
e rro r w ith r e s p e c t to th e w eig h ts in a n e u ra l n e tw o rk , e n a b lin g e ff ic ie nt w e ig h t
u p d a te s . T h e a lg o rith m e x p e rie n c e d s ig nific a nt a d va n c e m e n ts in th e 19 8 0 s , le a d in g
to re n e w e d in ter e s t in n e u ra l n e tw o rk s .

T h e s e e a rly n e ur a l ne tw o rk s fa c ed lim ita tio ns in te rm s o f c o m p u ta tio n a l


p o w e r, d a ta a v a ila b ility, a n d th e la c k o f s o p h is tic a te d tra in in g a lg o r ith m s . A s a re s u lt,
th e y w er e lim ite d to re la tiv e ly s im p le ta s k s a n d h ad o n ly a fe w la y er s . H o w e v er , th ey
la id th e g ro u nd w o rk fo r fu tu re b re a k th ro u g h s a n d s e t th e s ta g e fo r th e re s u rg e n c e o f
n e u ra l n e tw o rk s in th e 2 1 s t c e ntu ry, w ith th e d e v e lo p m e n t o f d ee p le a rn in g
a rc h ite c tu re s a n d p o w e rfu l tra in in g te c hn iq u e s .

Kernal Methods:
K e rn e l m e th o d s a re a fa m ily o f m a c hin e lea r nin g te c h n iq u e s th a t o p e ra te in a
h ig h - d im e n s io n a lfe a tu re s p a c e im p lic itly th ro u g h a k e rn e l fu n c tio n . T h e y a re
p a rtic u la rly u s e fu l fo r s o lv in g c o m p le x n o n lin e a r p ro b le m s w h ile p re s e rv in g the
c o m p uta tio n a l e ff ic ien c y o f lin e a r m e th o d s . K e rn e l m e th o d s h a ve ap p lic a tio ns in
v a rio u s fie ld s , in c lud in g c la s s ific a tio n , re g re s s io n , d im e n s io n a lity re d u c tio n , a n d
a n o m aly d e te c tio n .

H e r e a re s o m e k e y a s p e c ts o f k e rn e l m e th o d s :

1. K e rne l F un c tio n s : A k e rn e l f un c tio n m e a s u re s th e s im ila rity o r d is ta n c e


b etw e e n p a irs o f d a ta p o in ts in th e in p u t s p a c e . It ta k e s tw o in p u ts a n d re tu rn s a
s im ilar ity m e a s u re o r in n e r p ro d u c t in a h ig h - d im e n s io n al fe a tu re s p a c e . P o p u la r
k e rn e l fu n c tio n s in c lu d e th e lin e a r k e rn e l, p o ly no m ia l k e rn e l, G a u s s ian ( R B F ) k e rn e l,
a n d s ig m o id k er n el.

2. K e rn e l T ric k : T h e k e rn e l tric k is a c en tra l c o n c e p t in k e rn e l m e th o d s . It a llo w s


u s to im p lic itly m a p th e o rig in a l in p u t s p a c e in to a h ig h e r- d im e n s io n al fe a tu re s p a c e
w ith o u t e x p lic itly c o m p u tin g th e tra n s fo rm ed fe a tu re s . T h is is c o m p u ta tio n a lly
e ffic ie n t a s it a vo id s the n ee d to c o m p u te a n d s to r e th e h ig h - d im e n s io n al fe a tu r e
re p re s e n ta tio n s e x p lic itly.

3. S u p p o r t V e c to r M a c h in e s (S V M ) : S V M is a w id e ly u s e d k er n el- b a s ed a lg o rith m
lO M oAR cPSD |270 42294

fo r c las s ific a tio n an d re g re s s io n ta s k s . It a im s to fin d a h yp e r p la n e th a t s e p ar a te s


d a ta p o in ts o f d iffe re n t c la s s e s w h ile m a x im iz in g th e m a rg in b e tw e e n th e c las s e s .
S V M s u s e k e rn e l fu n c tio ns to im p lic itly o p e r ate in a h ig h - d im e n s io na l fe a tu re s p a c e
a n d f in d th e o p tim a l d e c is io n b o u n d a ry.

4. K e rn e l P C A : K e rn e l P rin c ip a l C o m p o n e n t A n a lys is (P C A ) is a n e x te n s io n o f
tra d itio n a l P C A th at u s e s k e rn e l fu n c tio n s to p e rfo rm n o n lin e a r d im e n s io na lity
re d u c tio n . It c a p tu re s n o n lin e a rn re la tio n s h ip s in th e d a ta b y m a p p in g it to a
h ig h - d im e n s io n a l fe a tu re s p a c e a n d c o m p u tin g p r in c ip a l c o m p o ne n ts in tha t
s p ac e .
lO M oAR cPSD |270 42294

5. G a u s s ia n P ro c e s s e s ( G P s ) : G a u s s ian p ro c e s s e s a re p ro b a b ilis tic m o d e ls th at


u s e k e rn e l fu n c tio ns to d ef in e th e c o va rian c e s tru c tu re b e tw e e n d a ta p o in ts . G P s
a re fle x ib le a n d c a n m o d e lc o m p lex n o n lin e a r re la tio n s h ip s w h ile p ro v id in g
u n c e rta in ty e s tim a te s . T h e y a re u s e d f o r r e g re s s io n , c la s s ific a tio n , a n d B a ye s ia n
o p tim iza tio n ta s k s .

6. K e rn e l- b a s e d C lu s te rin g : K e rn e l m e th o d s c a n a ls o b e a p p lie d to c lu s te r in g
a lg o rith m s , s u c h a s K er n el K - m e a n s a n d S p e c tra l C lu s te rin g . T h es e m e th o d s u s e
k e rn e l fu n c tio n s to m e a s u re s im ila rity o r d is s im ila rity b e tw e e n d a ta p o in ts an d g r o u p
th e m into c lu s te rs .

K e rn e l m e th o d s h a ve s ev e ra l a d v a n ta g e s , in c lu d in g th e ir a b ility to h a n d le
n o n lin e a r re latio n s h ip s , th e ir m a th e m a tic al e le g an c e , a n d th e ir in te rp re ta b ility.
H o w e v e r, th e y m a y f ac e c ha lle n g e s w ith s c a la b ility a n d h yp e rp a ra m e te r s e le c tio n .
N e v e rth e le s s , k er n el m eth o d s h av e h a d a s ig n ific a n t im p ac t o n th e fie ld o f m a c hin e
le a rn in g , p ro v id in g p o w er fu l to o ls f o r s o lvin g a w id e r a ng e o f p ro b le m s .

Decision Trees:

D e c is io n T re e is a Supervised learning technique th at c an b e us e d fo r b o th

c la s s ific a tio n a nd R e g r e s s io n p ro b le m s , b u t m o s tly it is p r e fe rre d fo r s o lv in g

C la s s ific a tio n p ro b lem s . It is a tr e e- s tru c tu re d c la s s ifie r , w h e re internal nodes

represent the features of a dataset, branches represent the decision rules a n d


each leaf node represents the outcome.
In a D e c is io n tre e , th e re a re tw o n o d e s , w h ic h a re th e Decision Node a n d Leaf

Node. D e c is io n no d e s a re u s e d to m a k e a n y d e c is io n a n d h a ve m u ltip le
b ra n c h e s , w h e re a s L e a f n o d e s a re th e o u tp u t o f tho s e d e c is io n s a n d d o n o t

c o n ta in a n y fu rth e r b ra n c h e s .

T h e d e c is io n s o r th e te s t a re p e rfo rm ed o n th e b a s is o f fe a tu re s o f th e g ive n
d a ta s e t.

It is c a lled a d e c is io n tre e b e c a u s e , s im ilar to a tr ee , it s ta rts w ith th e r o o t n o d e ,

w h ic h e x p a n d s o n fu rth e r b ra n c h e s a n d c o n s tru c ts a tre e - lik e s tru c tu re .


lO M oAR cPSD |270 42294

Decision Tree Terminologies


Root Node: Root node is from where the decision tree starts. It represents the
entiredataset, which further gets divided into two or more homogeneous sets.
Leaf Node: Leaf nodes are the final output node, and the tree cannot be
segregatedfurther after getting a leaf node.
Splitting: Splitting is the process of dividing the decision node/root node into
sub-nodesaccording to the given conditions.
Branch/Sub Tree: A tree formed by splitting the tree.
Pruning: Pruning is the process of removing the unwanted branches from the tree.
Parent/Child node: The root node of the tree is called the parent node, and other
nodesare called the child nodes.

Algorithm

Step-1: Begin the tree with the root node, says S, which contains the complete
dataset.
Step-2: Find the best attribute in the dataset using Attribute Selection Measure
(ASM).
Step-3: Divide the S into subsets that contains possible values for the best attributes.
Step-4: Generate the decision tree node, which contains the best attribute.
Step-5: Recursively make new decision trees using the subsets of the dataset
created in step -3. Continue this process until a stage is reached where you
cannot further classify the nodes and called the final node as a leaf node.
lO M oAR cPSD |270 42294

Random Forest:
Random Forest is an ensemble learning method that combines multiple decision trees to
make predictions or classifications. It is a powerful and widely used algorithm known for
its robustness and ability to handle complex datasets. Random Forest overcomes the
limitations ofindividual decision trees by reducing overfitting and improving generalization.
Here are the key characteristics and concepts of Random Forest:

1. Ensemble of Decision Trees: Random Forest consists of a collection of decision


trees, where each tree is trained on a random subset of the training data. Each tree
independently makes predictions, and the final prediction is determined by combining
the predictions of all the trees.

2. Random Sampling: Random Forest uses two types of random sampling. The first
type is random sampling with replacement, also known as bootstrap sampling. It
creates multiple bootstrap samples by randomly selecting data points from the training
dataset, allowing somedata points to be present in multiple subsets. The second type is
random feature selection, where only a subset of features is considered for splitting at
each node of the decision tree.

3. Voting for Predictions: Random Forest employs a majority voting scheme for
classification tasks and averaging for regression tasks. Each decision tree in the
ensemble makes an individualprediction, and the class with the most votes or the
average of the predicted values is chosen asthe final prediction.

4. Feature Importance: Random Forest can provide a measure of feature


importance based onthe average impurity decrease (such as Gini impurity or entropy)
caused by the feature across all decision trees in the forest. This information helps
identify the most informative features forthe task at hand.

5. Robust to Overfitting: By aggregating predictions from multiple decision trees,


Random Forestreduces overfitting. The individual decision trees in the ensemble can
overfit the training data, but the averaging or voting process helps generalize predictions
and reduces the impact of outliers or noisy data.

6. Parallelizable: Random Forest can be easily parallelized since each decision


tree in the ensemble can be trained independently. This allows for efficient
computation, especially forlarge datasets.
lO M oAR cPSD |270 42294

7. Versatility: Random Forest is applicable to both classification and regression


problems. Ithandles a mixture of feature types, such as categorical and numerical
features, without requiring extensive preprocessing.

Random Forest is widely used in various domains, including finance, healthcare,


marketing, and computer vision. Its versatility, robustness, and ability to handle high-
dimensional data make it a popular choice for many machine learning tasks.

Gradient Boosting Machines:


Gradient Boosting Machines (GBMs) are a powerful ensemble learning method that combines
multipleweak prediction models, typically decision trees, to create a strong predictive model.
GBMs iterativelybuild an ensemble of models by optimizing a loss function in a gradient descent
manner, focusing on reducing the errors made by the previous models in the ensemble. They
are known for their effectiveness in a wide range of machine learning tasks, including regression
and classification.

Here are the key characteristics and concepts of Gradient Boosting Machines:

1. Boosting: GBMs belong to the boosting family of algorithms, where weak models are
sequentially trained to correct the mistakes of the previous models. Each subsequent model in
the ensemble focuseson reducing the errors made by the previous models, leading to an
ensemble with improved overall predictive performance.

2. Gradient Descent: GBMs optimize the ensemble by minimizing a differentiable loss


function using gradient descent. The loss function measures the discrepancy between the
predicted values and the truevalues of the target variable. Gradient descent updates the model
parameters in the direction of steepest descent to iteratively improve the model's predictions.

3. Weak Learners: GBMs use weak learners as building blocks, typically decision trees with a
small depth(often referred to as "shallow trees" or "decision stumps"). These weak learners are
simple models thatmake predictions slightly better than random guessing. They are usually
shallow to prevent overfitting and to focus on capturing the specific patterns missed by previous
models.

4. Residuals: In GBMs, the subsequent weak learners are trained to predict the residuals (the
differencesbetween the true values and the predictions of the ensemble so far). By focusing on
the residuals, the subsequent models are designed to correct the errors made by the previous
models and improve the overall prediction accuracy.

5. Learning Rate: GBMs introduce a learning rate parameter that controls the contribution of
each weak learner to the ensemble. A smaller learning rate makes the learning process more
conservative, slowingdown the convergence but potentially improving the generalization ability.

6. Regularization: To prevent overfitting, GBMs often include regularization techniques.


Common regularization methods include limiting the depth or complexity of the weak learners,
applying shrinkage(reducing the impact of each weak learner), and using subsampling
techniques to train each weak learner on a random subset of the data.
lO M oAR cPSD |270 42294

7. Feature Importance: GBMs can provide estimates of feature importance based on how
frequently andeffectively they are used in the ensemble. This information helps identify the most
informative featuresfor the task.

Gradient Boosting Machines, particularly popular implementations such as XGBoost,


LightGBM,and CAT Boost, have achieved state-of-the-art performance in various machine
learning competitions and real-world applications. They excel at handling complex,
high-dimensional data and have become anessential tool in the machine learning practitioner's
toolkit.

Fundamentals of Machine Learning


Four Branches of Machine Learning:

Machine learning is a subset of AI, which enables the machine to automatically learn
from data, improve performance from past experiences, and make predictions.
M a c h in e le ar n in g c o n ta ins a s e t o f a lg o rith m s tha t w o rk o n a h u g e a m o u n t o f d a ta .
D a ta is f ed to th e s e a lg o rith m s to tra in th e m , a nd o n th e b a s is o f tra in ing , th e y b u ild
th e m o d e l & p e rfo r m a s p e c ific ta s k .

T h es e M L a lg o rith m s h e lp to s o lv e d if fe re n t b u s in e s s p ro b le m s lik e R e g re s s io n ,
C la s s ific a tio n ,F o re c a s tin g , C lu s te r in g , a n d A s s o c ia tio n s , etc .

B a s e d o n th e m e th o d s a n d w a y o f le a rn ing , m a c h in e le a rn in g is d ivid e d in to m ain ly


fo u r typ e s , w h ic h a re :

1 . S u p e rvis ed M a c h in e L e a rn in g

2 . U n s u p e rv is e d M a c hin e Le a rn in g
lO M oAR cPSD |270 42294

3 . S e m i- S u p e rv is e d M a c h in e L e a rn in g
lO M oAR cPSD |270 42294

4 . R e in fo rc e m e n t L e a rn in g

In th is to p ic , w e w ill p ro v id e a d e ta ile d d e s c rip tio n o f th e ty p e s o f M a c h ine L e a rn in g


a lo n g w ith th e ir re s p e c tiv e a lg o r ith m s :

1. S up e rvise d M a ch ine Le a rn ing


As its name suggests, Supervised machine learning is based on supervision. It means in the
supervisedlearning technique, we train the machines using the "labelled" dataset, and based
on the training, themachine predicts the output. Here, the labelled data specifies that some of
the inputs are already mapped to the output. More preciously, we can say; first, we train the
machine with the input and corresponding output, and then we ask the machine to predict the
output using the test dataset.

L e t's u n d e rs ta n d s u p e rv is e d le a rn in g w ith a n e x a m p le . S u p p o s e w e h a ve a n in p u t
d ata s et o f c ats a n d d o g im a g e s . S o , firs t, w e w ill p ro vid e th e tra in in g to th e m a c h in e
to u n d er s ta n d th e im a g e s , s u c h a s th e shape & size of the tail of cat and dog, Shape
of eyes, colour, height (dogs are taller, cats are smaller), etc. A fte r c o m p le tio n o f
tra in in g , w e in p ut th e p ic tu re o f a c a t a n d a s k th e m a c hin e to id e n tify th e o b je c t a n d
p re d ic t th e o u tp u t. N o w , th e m a c h in e is w e ll tr ain e d , s o it w ill c h e c k a ll th e fe a tu re s
o f th e o b je c t, s u c h a s h e ig h t, s h a p e , c o lo u r, e ye s , e a rs , ta il, e tc ., an d fin d th a t it's a
c at. S o , it w ill p u t it in th e C a t c a te g o ry . T h is is th e p ro c e s s o f h o w th e m a c h in e
id e n tifies th e o b je c ts in S up e rvis e d L e a rn in g .

The main goal of the supervised learning technique is to map the input variable(x)
with the output variable(y). S o m e r ea l- w o rld a p p lic a tio ns o f s u p e rv is e d le a rn in g a re
Risk Assessment, Fraud Detection, Spam filtering, e tc .

C a te g orie s o f S u pe rvise d M a ch in e Le a rn in g
S u p e rvis e d m a c h in e le a rn in g c a n b e c la s s ifie d in to tw o typ e s o f p ro b le m s , w h ic h a re
g ive n b e lo w :

Classification
lO M oAR cPSD |270 42294

Regression
lO M oAR cPSD |270 42294

a) Cla ss ific a tio n


C la s s ific a tio n a lg o rith m s a re u s e d to s o lve th e c la s s ific a tio n p r o b le m s in w h ic h th e
o u tp u tv a ria b le is c a te g o ric a l, s u c h a s " Yes" or No, Male or Female, Red or Blue, etc.
T h e c la s s ific a tio n a lg o rith m s p re d ic t th e c a te g o ries p re s e n t in th e d a ta s e t. S o m e re a l-
w o rld e x a m p le s o f c la s s if ic a tio n a lg o rith m s a re Spam Detection, Email filtering, etc.

S o m e p o p u la r c la s s if ic a tio n a lg o rith m s a re g ive n b e lo w :

Random Forest Algorithm


Decision Tree Algorithm
Logistic Regression Algorithm
Support Vector Machine Algorithm
b ) R eg res sio n
R e g r es s io n a lg o rith m s a re u s e d to s o lv e r e g re s s io n p ro b le m s in w h ic h th e re is a
lin e a r re la tio n s h ip b e tw e e n in p u t a n d o u tp u t v a ria b le s . T h e s e a re u s e d to p re d ic t
c o n tin u o u s o u tp u t v a ria b le s , s u c h a s m a rk e t tre n d s , w e a th e r p re d ic tio n , e tc .

S o m e p o p u la r R e g re s s io n a lg o r ith m s a re g ive n b e lo w :

Simple Linear Regression Algorithm


Multivariate Regression Algorithm
Decision Tree Algorithm
Lasso Regression

A d va n ta g e s a n d D isa d va n ta g e s of S u p e rvis e d Le a rn in g
Advantages:

S in c e s u p e rv is e d le a rn in g w o rk w ith th e la b e lle d d a ta s e t s o w e c a n h av e a n

e x a c t id e a a b o u t th e c la s s e s o f o b je c ts .

T h e s e a lg o rithm s ar e h e lp fu l in p r ed ic tin g th e o u tp ut o n th e b a s is o f p rio r


e x p er ie n c e .
Disadvantages:

T h e s e a lg o rithm s ar e n o t a b le to s o lv e c o m p le x ta s k s .

It m a y p re d ic t th e w ro n g o u tp u t if th e te s t d a ta is d iffe re n t f ro m th e tra in in g d a ta .

It re q u ire s lo ts o f c o m p u ta tio n a l tim e to tra in th e a lg o r ith m .

A p plic a tion s o f Su p e rvis e d L e a rn in g


S o m e c o m m o n a p p lic a tio n s o f S u p er vis e d L e a rn in g a re g ive n b e lo w :

Image Segmentation:
lO M oAR cPSD |270 42294

Supervised Learning algorithms are used in image segmentation. In this


process,image classification is performed on different image data with
pre-defined labels.
lO M oAR cPSD |270 42294

Medical Diagnosis:
Supervised algorithms are also used in the medical field for diagnosis
purposes. It is done by using medical images and past labelled data with
labels for disease conditions. With such a process, the machine can identify a
disease for the new patients.
Fraud Detection - S u p er vis e d Le a rn in g c la s s ific a tio n a lg o rith m s a re us e d fo r
id e n tify in g fra u d tr an s a c tio n s , fr a ud c u s to m e rs , e tc . It is d o n e b y u s in g h is to r ic

d ata to id e n tify th e p a tte rn s th a t c an lea d to p o s s ib le fra u d .

Spam detection - In s p a m d ete c tio n & filte rin g , c la s s ific a tio n a lg o rith m s a re
u s e d . T h e s e alg o rith m s c la s s if y a n e m a il a s s p a m o r n o t s p a m . T h e s p a m

e m a ils a re s e nt to th e s p a m fo ld e r .

Speech Recognition - S u p e rvis e d le a rn in g a lg o rith m s a re a ls o u s e d in s p ee c h


re c o g n itio n. The a lg o rith m is tra ine d w ith v o ic e d a ta , and va rio u s

id e n tific a tio n s can be d one u s in g th e sa m e, suc h as v o ic e - a c tiva te d

p as s w o rd s , vo ic e c o m m a n d s , e tc .

2 . U ns up e rvise d M a c hin e Le a rn ing


U n s u p e rv is e d le a rn in g is d iffe re n t fr o m th e S u p e rv is e d le a rn in g tec h n iq u e ; a s its
n a m e s u g g e s ts , th e re is n o n e e d fo r s u p e rv is io n . It m e an s , in u n s u p e rv is e d m ac h in e
le a rn in g , th e m a c h in e is tra ine d u s in g the u n la b e le d d a ta s e t, a n d th e m ac h in e
p re d ic ts th e o u tp u t w itho u t a n y s up e rvis io n .

In un s u p e rvis ed le a rn ing , th e m o d e ls a re tra ine d w ith th e d a ta th a t is n e ith e r


c la s s ifie d n o r la b e lle d , a n d th e m o d e l a c ts o n tha t d a ta w ith o u t a n y s u p e rvis io n .

The main aim of the unsupervised learning algorithm is to group or categories the
unsorted dataset according to the similarities, patterns, and differences. M a c h in e s
a re in s tru c ted to find th e h id d e n p a tte rn s fro m th e in p ut d a ta s e t.

L e t's ta k e a n e x a m p le to u n d e rs tan d it m o re p re c io u s ly ; s u p p o s e th e re is a b a s k et o f
fr uit im a g e s , an d w e in p u t it in to th e m a c h in e le a rn in g m o d e l. T h e im a g e s a re to ta lly
u n k n o w n to th e m o d e l, a n d th e ta s k o f th e m a c h in e is to fin d th e p a tte rn s a n d
c a te g o r ie s o f th e o b je c ts .

S o , n o w th e m a c h in e w ill d is c o ve r its p a tte rn s a n d d iffe re n c e s , s u c h a s c o lo ur


d iffe re n c e, s h a p e d iffe re n c e , a n d p re d ic t th e o u tp u t w h e n it is te s te d w ith th e te s t
d a ta s e t.

C a te g orie s o f U n su p e rv is e d M a c h in e L e a rn in g
lO M oAR cPSD |270 42294

U n s u p e rv is e d L e a rn in g c a n b e fu r th e r c la s s ifie d in to tw o ty p e s , w h ic h a re g ive n b e lo w :

Clustering
Association
1) C lus te ring
T h e c lu s te rin g te c hn iq u e is u s e d w h e n w e w a n t to fin d th e in h e re n t g ro u p s fro m th e
d a ta . It is a w a y to g ro u p th e o b jec ts in to a c lu s te r s u c h th a t th e o b je c ts w ith the
m o s t s im ilar itie s re m a in in
lO M oAR cPSD |270 42294

o n e g ro u p a n d h a ve fe w e r o r n o s im ila rities w ith th e o b je c ts o f o th e r g ro u p s . A n


e x a m p le o f th e c lu s te rin g a lg o rith m is g ro u p in g th e c u s to m e rs b y th e ir p u r c h a s in g
b e ha v io ur .

S o m e o f th e p o p u la r c lu s te ring a lg o rith m s a re g iv en b e lo w :

K-Means Clustering algorithm


Mean-shift algorithm
DBSCAN Algorithm
Principal Component Analysis
Independent Component Analysis
2 ) A ss o c ia tio n
A s s o c ia tio n ru le le ar n in g is an u n s up e rvis e d le ar n in g te c hn iq u e , w h ic h f in d s
in te re s tin g re la tio n s a m o n g v a ria b le s w ith in a la rg e d a ta s e t. T h e m a in a im o f th is
le a rn in g a lg o rith m is to fin d th e d e p e n d en c y o f o n e d a ta ite m o n a n o th e r d ata ite m
a n d m a p th o s e v a ria b le s a c c o rd in g ly s o th a t it c a n g en e ra te m a x im u m p ro f it. T h is
a lg o rith m is m ain ly a p p lie d in Market Basket analysis, Web usage mining,
continuous production, e tc .

S o m e p o p u la r a lg o rith m s o f A s s o c ia tio n ru le le a rn in g a re Apriori Algorithm, Eclat, FP-


growthalgorithm.

A d van tag e s a n d D isa d va n ta ge s o f U n s u pe rvise d Le a rn in g


A lg o rith m
Advantages:

T h e s e a lg o rith m s c a n b e u s e d fo r c o m p lic a te d ta s k s c o m p a r ed to th e

s u p e r vis e d o n e s b e c a u s e th e s e a lg o rith m s w o rk o n the u n la b e le d d a tas e t.

U n s u p e rv is e d a lg o rithm s a re p r e fe ra b le fo r v a rio u s ta s k s a s g e ttin g th e


u n la b e le d d a ta s e t

is e a s ie r as c o m p a re d to th e la b e lle d d ata s et.


Disadvantages:

T h e o u tp u t o f a n u n s u p e rv is e d a lg o rith m c a n b e le s s a c c u ra te a s th e

d a ta s e t is n o tla b e lle d , a n d a lg o rith m s a re n o t tra in e d w ith th e e x a c t o u tp ut in

p rio r .

W o rk in g w ith U n s u p e r vis e d le a rn ing is m o r e d iffic u lt a s it w o rk s w ith th e

u n la b e lle d d a ta s e t th a t d o e s n o t m a p w ith th e o u tp u t.

A p plic a tion s o f U n su p e rvis e d Le a rn in g


lO M oAR cPSD |270 42294

Network Analysis: U n s u p e r vis e d le a rn in g is u s e d fo r id e n tifying p la g ia ris m a n d


c o p y rig h t in d o c u m e nt n e tw o rk a n a lys is o f te x t d a ta f o r s c h o la rly a r tic le s .

Recommendation Systems: R e c o m m e n d a tio n s y s te m s w id e ly use

u n s u p e rv is e d le a rn in g tec h n iq u e s fo r b u ild in g r ec o m m e n d a tio n a p p lic a tio n s

fo r d iffe re n t w e b a p p lic a tio n s a n d e - c o m m e rc e w e b s ite s .


lO M oAR cPSD |270 42294

Anomaly Detection: A n o m a ly d e te c tio n is a p o p u la r a p p lic a tio n of

u n s u p e rv is e d le ar n in g , w h ic h c a n id e n tif y u n u s u a l d a ta p o in ts w ith in th e

d ata s et. It is u s e d to d is c o ve r fra u d u le n t tra n s a c tio n s .

Singular Value Decomposition: S in g u la r V a lue D e c o m p o s itio n o r S V D is u s e d to


e x tra c t p a rtic u la r in fo rm a tio n fro m th e d a ta b a s e . F o r e x a m p le , e x tra c tin g

in f o rm a tio n o f e a c h u s e r lo c a te d a t a p a rtic u la r lo c a tio n .

3 . S e m i- S u p e rvis e d Le a rnin g
Semi-Supervised learning is a type of Machine Learning algorithm that lies between
Supervised and Unsupervised machine learning . It re p re s e n ts th e in te rm e d ia te
g ro u n d b etw e e n S u p er vis e d ( W ith L a b e lle d tra in in g d a ta ) a n d U n s u p e rv is e d le a rn in g
( w ith n o la b e lled tra in in g d a ta ) a lg o r ith m s a n d u s e s th e c o m b in a tio n o f la b e lle d a n d
u n la b e le d d a ta s e ts d ur in g th e tra in in g p er io d .

Alth o u g h S e m i- s u p e rv is e d le a rn in g is th e m id d le g ro u n d b e tw e e n s u p e rv is e d an d
u n s u p e rv is e d le a rn in g a n d o p e ra te s o n th e d a ta th a t c o ns is ts o f a fe w la b e ls , it
m o s tly c o n s is ts o f u n la b e le d d a ta . A s la b e ls a re c o s tly, b u t fo r c o rp o ra te p u rp o s e s ,
th e y m ay h a ve fe w la b e ls . It is c o m p lete ly d iffe re n t fro m s u p e rv is e d an d
u n s u p e rv is e d le a rn in g a s th ey a re b a s e d o n th e p re s e nc e & ab s e n c e o f la b e ls .

To overcome the drawbacks of supervised learning and unsupervised learning


algorithms, the concept of Semi-supervised learning is introduced . T h e m a in a im o f
s e m i- s u p e rvis ed le a rn in g is to e ff ec tiv e ly u s e a ll th e a va ila b le d a ta , r a th e r th a n o n ly
la b e lle d d a ta lik e in s u p e rv is e d le a rn in g . In itia lly, s im ila r d a ta is c lu s te r ed a lo ng w ith
a n u n s u p e rv is e d le a rn in g a lg o rith m , an d fu rth e r, it h e lp s to la b el th e u n la b e le d d a ta
in to lab e lle d d a ta . It is b e c a us e la b e lle d d a ta is a c o m p a ra tive ly m o re ex p e n s ive
a c q u is itio n th an u nla b ele d d a ta .

W e c a n im a g ine th e s e a lg o rith m s w ith a n e x a m p le . S u p e rvis e d le a rn in g is w h e re a


s tu d e nt is u n d er th e s u p e rv is io n o f a n in s tru c to r a t h o m e a n d c o lleg e . F ur th e r, if th a t
s tu d e nt is s e lf- a na ly s in g th e s a m e c o n c e p t w ith o u t a n y h e lp fro m the in s tr uc to r , it
c o m e s u n d e r u n s u p e rv is e d le a rn in g . U n d e r s e m i- s u p e rv is e d le ar n in g , the s tu d e n t
h a s to re vis e h im s e lf a fte r a n a lyz in g th e s a m e c o n c ep t u n d e r th e g u id a nc e o f an
in s tru c to r a t c o lle g e .

A d va n ta g e s a n d d isa d va n ta g e s of S e m i- s u pe rvise d L e a rn in g
Advantages:

It is s im p le a n d e a s y to u n d er s ta n d th e a lg o rith m .

It is h ig h ly e ffic ie n t.
lO M oAR cPSD |270 42294

It is u s e d to s o lv e d ra w b a c k s o f S up e rvis e d a n d U n s u p e rv is e d L e ar n in g
a lg o rith m s .
Disadvantages:

Ite ra tio n s re s u lts m a y n o t b e s ta b le.

W e c a n n o t a p p ly th e s e a lg o rith m s to n e tw o rk - le ve l d a ta .
lO M oAR cPSD |270 42294

A c c u ra c y is lo w .

4 . R e in fo rc e m e nt Le a rnin g
Reinforcement learning works on a feedback-based process, in which an AI agent
(A software component) automatically explore its surrounding by hitting & trail,
taking action, learning from experiences, and improving its performance. A g e n t g e ts
re w a rd e d fo r e a c h g o o d ac tio n a n d g e t p u n is h e d f o r e a c h b a d a c tio n ; h e n c e th e
g o a l o f re in fo rc e m e n t le a rn in g a g e n t is to m a x im ize th e r e w a rd s .

In re in fo rc e m e n t le a rn in g , th e re is no la b e lle d d a ta lik e s u p e rv is e d le a rn in g , a n d
a g en ts le ar n fro m th e ir e x p e rie n c e s o n ly.

T he r e in fo rc e m e n t le a rn in g p ro c e s s is s im ila r to a hu m a n b e in g ; fo r e x a m p le , a c h ild
le a rn s v a rio u s th in g s by e x p e rie n c e s in h is d a y - to - d a y life . A n e x a m p le of
re in f o rc em en t le a rn in g is to p la y a g a m e , w h e re th e G a m e is th e e n viro n m e n t,
m o ve s o f a n a g e n t a t e a c h s te p d e fin e s ta tes , a n d th e g o a l o f th e a g e n t is to g e t a
h ig h s c o re . A g e n t re c e ive s fe e d b a c k in te rm s o f p u n is h m e n t a n d re w a rd s .

D u e to its w a y o f w o rk in g , re in fo rc e m e n t lea r nin g is e m p lo y e d in d iffe re n t fie ld s s u c h


a s Game theory, Operation Research, Information theory, multi-agent systems.

A re in fo rc e m e n t le ar n in g p ro b le m c an be fo rm a liz e d us in g Markov Decision


Process(MDP). In M D P , th e a g e n t c o n s ta n tly in te ra c ts w ith the e n viro n m e n t a n d
p e rfo rm s a c tio n s ; a t e a c h a c tio n , th e e n viro n m e n t re s p o n d s a n d g e n e ra te s a n e w
s ta te.

C a te g orie s o f R e in force m e n t Le a rn in g
R e in fo rc e m e n t le a rn in g is c a te g o riz e d m a inly in to tw o ty p e s o f m e th o d s / a lg o rith m s :

Positive Reinforcement Learning: P o s itiv e re in fo rc e m e n t le a rn in g s p e c ifie s


in c re a s in g th e te n d e n c y th a t th e re q u ire d b e h a v io r w o u ld o c c u r a g a in b y

a d d in g s o m e th in g . It e n h a n c e s th e s tre n g th o f th e b e h a v io r o f the a g e n t a n d

p o s itive ly im p a c ts it.

Negative Reinforcement Learning: N e g a tiv e re in fo r c e m e n t le a rn in g w o rk s


e x a c tly o p p o s ite to th e p o s itive R L . It in c r e as e s th e te n d e n c y th a t the s p e c ific

b eh a v io u r w o u ld o c c ur a g a in b y a vo id ing th e n e g ative c o nd itio n .

R e a l-w orld U s e c a se s o f R ein force m e n t Le a rn in g


V id e o G am es :

R L a lg o rith m s a re m u c h p o p u la r in g a m ing a p p lic a tio n s . It is u s e d to g a in

s u p e r -h u m a n p e r fo rm a n c e . S o m e p o p u la r g a m e s th a t u s e R L a lg o r ith m s a re
lO M oAR cPSD |270 42294

A lp h aG O a n d A lp h a G O Z e ro .

R e s o u rc e
M a n a g em en
t:

The " R e s o u rc e M a n ag e m e n t w ith Deep R e in fo rc e m e n t L ea r nin g " p aper


s h o w e d th a t h o w
lO M oAR cPSD |270 42294

to u s e R L in c o m p u te r to au to m a tic a lly le a rn an d s c h e d u le re s o ur c e s to w a it

fo r d iffe re n t jo b s in o rd e r to m in im iz e a ve ra g e jo b s lo w d o w n .

R o b o tic s :

R L is w id e ly b e in g u s e d in R o b o tic s a p p lic a tio n s . R o b o ts a re u s e d in the

in d u s tria l a n d m a n u fa c tu rin g a re a , a n d th e s e ro b o ts a re m ad e m o re p o w e r fu l

w ith re in fo rc e m e n t le a rn in g . T h e re a re d iffe re n t in d u s trie s th at h a v e th e ir

v is io n o f b u ild in g in tellig e n t ro b o ts u s in g A I a n d M a c h in e le a rn in g te c h n o lo g y .

Text M in in g

T ex t- m in in g , o n e o f th e g r ea t a p p lic a tio n s o f N L P , is n o w b e in g im p lem en te d

w ith th e h e lp o f R e in fo rc e m e n t L e a rn in g b y S a le s fo r c e c o m p a n y .

A d va n ta g e s a n d D isa d va n ta g e s of R e in fo rc em e n t L e a rn in g
Advantages

It h e lp s in s o lvin g c o m p le x re a l- w o rld p ro b le m s w h ic h a re d iffic u lt to b e

s o lv e d b y g e n e ra l te c h n iq u e s .

T h e le a rn ing m o d e l o f R L is s im ila r to th e le a rn in g o f hu m a n b e in g s ; h e n c e

m o s t a c c u ra te re s u lts c a n b e fo u n d .

H e lp s in a c h ie v in g lo ng te rm re s u lts .
Disadvantage

R L a lg o r ith m s a re n o t p re fe rr e d fo r s im p le p ro b le m s .

R L a lg o r ith m s re q u ire h u g e d ata an d c o m p u ta tio n s .


T o o m u c h re in fo rc e m e n t le ar n in g c a n le a d to a n o v e rlo a d o f s ta te s w h ic h c a n
w e a k e n th e re s u lts .
T he c u rs e o f d im e n s io n a lity lim its re in f o rc em en t le a rn in g fo r re a l p h ys ic a l s ys te m s .

Evaluating Machine learning Models:


M a c hin e le ar n in g is a fie ld o f s tu d y a n d a p p lic atio n th a t fo c u s e s o n d e ve lo p in g
a lg o rith m s a n d m o d els th a t en a b le c o m p u te rs to le a rn a n d m a k e p re d ic tio n s o r
d ec is io n s w itho u t b e in g e x p lic itly p ro g ra m m e d . It in v o lv es th e d e v e lo p m e n t o f
m a th e m a tic a l a n d s ta tis tic a l te c h n iq u e s th at a llo w s ys te m s to a u to m atic a lly le ar n
p atte rn s a n d re la tio n s h ip s fro m d a ta a n d im p ro ve th e ir p e rfo rm a n c e th ro u g h
e x p e r ie n c e .

H e r e a re s o m e fu n d a m e n ta l c o n c e p ts o f m a c h in e le a rn in g

1. D a ta : M a c h ine le a rn in g a lg o rith m s r e ly o n d a ta to le a rn a n d m a k e p r ed ic tio n s .


lO M oAR cPSD |270 42294

T h e d ata c o n s is ts o f in p u t va ria b le s ( fe a tu re s ) a nd c o r re s p o n d in g o u tp u t va riab le s


( ta rg ets o r la b e ls ) . T h e q ua lity, q u a ntity , a n d re p re s e n ta tive n e s s o f th e d a ta p la y a
c ru c ia l r o le in the s u c c e s s o f m a c h in e le a rn in g m o d els .
lO M oAR cPSD |270 42294

2. T r a in in g , V a lid a tio n , a n d T e s tin g : In m a c h in e le a rn in g , th e a v a ila b le d a ta is


ty p ic a lly d ivid e d in to th re e s e ts : th e tra in in g s e t, th e v a lid a tio n s e t, a n d th e te s tin g s e t.
T he tra in in g s e t is u s e d to tr a in th e m o d e l b y ad ju s ting its p a ra m e te rs b a s e d o n the
in p u t- o u tp u t p a tter n s . The va lid a tio n s et is used to fin e - tu n e th e m o d e l's
h y p e rp a ra m e te rs a n d a s s e s s its p e rf o rm a n c e d u rin g tra in ing . T h e te s tin g s e t is u s e d
to e va lu a te th e f in a l p e rfo rm a n c e o f th e tr ain e d m o d e l o n un s e e n d a ta .

3. S u p e rvis ed L e a rn in g : In s up e rvis e d le a rn in g , th e g o a l is to le a rn a m a p p in g
fu n c tio n th a t c a n p re d ic t th e o u tp ut v ar ia b le g iv en th e inp u t v a ria b le s . T h e tra in in g
d ata c o n s is ts o f la b e le d e x a m p les , w h e re b o th th e in p u t a nd th e d e s ire d o u tp u t a re
k n o w n . S u p e rvis e d le a rn in g a lg o rithm s inc lu d e re g re s s io n (p re d ic tin g c o n tinu o u s
v a lu e s ) a n d c la s s ific a tio n ( p re d ic tin g c a te g o ric a l va lu e s ).

4. U n s u p e rv is e d L e a rn in g : In u n s u p e rv is e d le a rn in g , th e g o a l is to d is c o v e r
p atte rn s o r s tru c tu r es in th e d a ta w ith o u t e x p lic it la b e ls o r ta r g e t va ria b le s .
U n s u p e rv is e d le a rn in g a lg o rith m s in c lu d e c lu s te rin g (g ro u p in g s im ila r d a ta p o in ts
to g e th e r) a n d d im e n s io n a lity re d u c tio n (re d u c in g th e n u m b e r o f in p u t va riab le s w h ile
p re s e rvin g im p o rtan t in fo r m a tio n ) .

5. F e a tu r e E ng in e e rin g : F ea tur e e n g in e e rin g is th e p ro c e s s of s e le c ting ,


tra n s fo rm in g , a n d c re a tin g re lev a n t f e atu re s fro m th e ra w d a ta to im p ro ve th e
p er fo rm a n c e o f m a c h ine le ar n in g m o d e ls . It in vo lv e s d o m a in k no w le d g e , d ata
e x p lo ra tio n , and v a rio us tec h n iq u e s suc h as n o rm a liza tio n , s c a lin g , one-hot
e n c o d in g , a n d fe a tu r e ex tra c tio n .

6. M o d e l E v a lu a tio n a n d S e le c tio n : T h e p e rfo rm a n c e o f m a c h in e le a rn in g m o d e ls


n e e d s to b e e va lu a te d to a s s e s s th e ir e ff e c tiv e n e s s . C o m m o n e v alu a tio n m e tric s
d ep e n d o n th e ta s k a n d c a n in c lu d e a c c ur a c y, p re c is io n , re c a ll, F 1 s c o re , m e a n
s q ua r ed e rro r, o r a re a u n d e r th e re c e ive r o p e ra tin g c h a ra c te ris tic c u rv e (A U C - R O C ) .
M o d e l s e le c tio n in v o lve s c o m p a rin g a n d c h o o s in g th e b e s t- p er fo rm in g m o d e l b as e d
o n th e e va lu a tio n m e tric s .

7. G e n er a liza tio n a nd O ve rf itting : M a c h in e le a rn in g m o d els s h o u ld b e a b le to


g en e ra liz e w e ll to un s e e n d ata , m e a n in g th e y c an m a k e a c c u ra te p r e d ic tio ns o n
n e w , u n s e e n ex a m p le s . O ve rf itting o c c u rs w he n a m o d e l le a rn s th e tra in in g d a ta to o
w e ll, c a p tu rin g n o is e a n d irre le va n t p a tte rn s , w h ic h c a n le a d to p o o r p e rfo r m a n c e o n
n e w d a ta . T e c h n iq u e s lik e c ro s s - va lid a tio n a n d re g u la riz atio n a re u s e d to p re v e n t
o ve rfittin g .

8. B ia s - V a ria n c e T ra d e o ff: T h e b ia s - va rian c e tra d e o ff is a k e y c o n c e p t in


m a c hin e le a rn in g . B ia s re fe rs to th e e rro r in tro d uc e d b y th e m o d e l's a s s u m p tio n s
a n d s im p lific a tio n s , w h ile v a ria n c e re fe rs to th e m o d e l's s e ns itiv ity to flu c tu atio n s in
th e tra in in g d ata . F in d in g the r ig h t b a la n c e b e tw e e n b ia s a n d v a ria n c e is c ru c ia l to
lO M oAR cPSD |270 42294

a c h ie ve a m o d e l th a t c a n g e n e ra liz e w e ll.

9. M o d e l D e p lo y m e n t a n d M o n ito rin g : O n c e a m a c h in e le a rn ing m o d e l is tra ine d


a n d e v a lua te d , it c a n b e d e p lo ye d to m a k e p r ed ic tio n s o n n e w , re a l- w o rld d ata .
M o d e l p e rfo rm a n c e s h o u ld b e c o n tin uo u s ly m o n ito re d , a n d m o d e ls m a y n e e d to b e
re tr a in e d o r u p d a te d p e rio d ic a lly a s n e w d a ta b e c o m e s a va ila b le o r a s re q u ire m e n ts
c h an g e .

M a c h in e le a rn in g is a d yn a m ic a n d r ap id ly e vo lvin g fie ld w ith a w id e ra n g e o f


a lg o rith m s , te c h n iq u e s , a n d a p p lic a tio n s . U n d e rs ta n d in g th es e fu n d a m e n ta l
c o n c e p ts p r o vid e s a s o lid
lO M oAR cPSD |270 42294

fo u n d a tio n fo r d ivin g d e e p e r in to th e v a rio u s a s p e c ts o f m a c h in e le ar n in g an d


d ev e lo p in g ef fe c tive m o d e ls fo r s o lv in g re a l-w o rld p r o b le m s .

Overfitting and Underfitting:


O v e rfittin g a nd u n d e rf itting a re tw o c o m m o n p ro b lem s in m a c h in e le a rn in g th a t a ris e
w h e n a m o d e l's p e rfo rm a n c e o n th e tr ain in g d a ta d o e s n o t g e n e ra liz e w ell to u n s e e n
d ata . T h e s e is s u e s a ffe c t th e m o d e l's a b ility to m a k e a c c u ra te p re d ic tio n s o n n ew
e x a m p le s . U n d e rs ta n d in g o v e rfittin g a n d u n d e r fittin g is c ru c ia l fo r b u ild in g re lia b le
a n d e ff e c tiv e m a c h ine le a rn in g m o d e ls .

1. Overfitting:
O v e rfittin g o c c u rs w h e n a m o d e l le a rn s th e tra in ing d a ta to o w e ll, c a p tu rin g n o is e
a n d ra n d o m va ria tio n s th a t a r e s p e c ific to th e tra in in g s e t b u t d o n o t e x is t in th e
u n d e rly in g p o p u la tio n o r th e te s t d ata . S ig n s o f o ve rfittin g in c lu d e:

- H ig h tra in in g a c c u ra c y b u t p o o r p e rfo rm a n c e o n th e te s t/v alid a tio n d a ta .

- T h e m o d e l c a p tu re s th e n o is e an d o u tlie r s in th e tra in in g d ata , le a d in g to p o o r


g e n e ra liz atio n .

- T h e m o d e l is e x c e s s iv e ly c o m p le x a nd h a s to o m an y p a r am ete rs , w h ic h a llo w s
it to m e m o rize the tra in in g e x a m p le s in s tea d o f le ar n in g th e u nd e rlying p atte rn s .

- O v e rly fle x ib le m o d els lik e d e e p n e u ra l n e tw o rk s c a n b e p ro n e to o ve r fittin g ,


e s p e c ia lly w ith lim ite d tra in in g d ata .

T o m itig a te o v e rfittin g , th e fo llo w in g s tra te g ie s c a n b e e m p lo y e d :

- In c re a s e th e s ize o f th e tra in ing d a tas e t to p ro v id e m o re d ive rs e e x a m p le s .

- U s e te c h n iq u e s lik e c ro s s - va lid a tio n o r tra in /te s t s p lit to e va lu a te th e m o d e l's


p er fo rm a n c e o n u n s e e n d a ta .

- R e g u la riz a tio n m e th o d s lik e L 1 o r L 2 re g u la riz a tio n c a n b e a p p lie d to p e n a liz e


c o m p le x m o d e ls an d re d u c e th e im p a c t o f no is e in th e tra in in g d a ta .

- S im p lify th e m o d e l b y re d u c in g th e n u m b e r o f p a ra m e te rs , lim itin g th e d ep th o f


d ec is io n tre e s , o r re d u c in g th e c o m p le x ity o f n e u ra l n e tw o rk s .

- F e a tu r e s e le c tio n o r d im e n s io n a lity re d u c tio n te c h niq u e s c a n h e lp re m o v e


ir re le v a n t o r n o is y fe a tur e s .

2. Underfitting:
U n d e rfittin g o c c u rs w h e n a m o d e l is to o s im p le to c a p tu re th e u n d e r ly in g p a tte rn s in
th e d a ta . It fa ils to le a rn th e im p o r ta n t re la tio n s h ip s b e tw e e n th e in p u t fe a tu re s a n d
lO M oAR cPSD |270 42294

th e ta rg et v a ria b le , re s u ltin g in p o o r p e rfo rm a n c e o n b o th th e tra in in g a n d te s t d a ta .


S ig n s o f u n d e rfittin g in c lu d e :

- L o w tr ain in g a c c u ra c y a n d p o o r p e rfo rm a n c e o n b o th th e tra in in g a n d te s t/ va lid a tio n


d ata .

- T h e m o d e l is to o s im p le a n d d o e s n o t c a p tu re th e c o m p le x itie s o f th e d a ta .
lO M oAR cPSD |270 42294

- T h e m o d e l fa ils to le ar n im p o rta n t p atte rn s o r re latio n s h ip s in th e d a ta .

T o a d d re s s u n d e rfittin g , th e fo llo w in g s tra te g ie s c a n b e u s ed :

- In c re a s e th e c o m p le x ity o f th e m o d e l b y a d d in g m o re p a ra m e te rs o r u s in g
m o re s o p h is tic a te d a lg o rith m s .

- C o lle c t m o re re le va n t fe a tu re s o r c re a te n e w fe a tu re s th a t p r o v id e m o re
in f o rm a tio n to th e m o d e l.

- A d ju s t h yp er p a ra m e te rs o f th e m o d e l, s u c h a s le a rn in g ra te, re g u la riz a tio n


s tr en g th , o r tre e d e p th , to im p ro v e its p e rfo r m a n c e .

- C o n s id e r u s in g m o r e a d v a nc e d m o d e ls tha t a re b ette r s u ite d to c a p tu re


c o m p le x p a tte rn s in th e d a ta .

B a la n c in g b e tw e e n o ve rfittin g a n d u n d e rfittin g is c r u c ia l to a c hie ve a m o d e l th a t


c a n g e n e ra liz e w e ll to u n s e e n d a ta . It in vo lv e s fin d in g th e rig h t le v e l o f m o d e l
c o m p le x ity th a t c ap tu re s the u n d e rlyin g p a tte rn s w itho u t b e in g to o s e n s itiv e to
n o is e o r to o s im p lis tic to c a p tu re th e re le v an t in fo rm a tio n . R e g u la r e va lu a tio n
te c h n iq u e s , su ch as c r o s s - v alid a tio n , can h elp in a s s e s s in g a m o d e l's
p e rfo rm a n c e a n d d e tec tin g s ig n s o f o ve rfittin g o r u n d e r fittin g .
lO M oAR cPSD |270 42294

l OMoA RcPS D|2 704229 4

U N IT 2
lO M oAR cPSD |270 42294

UNIT II: Introducing Deep Learning: B io lo g ic a l a n d M a c h in e V is io n , H u m a n a n d


M a c h in e L a n g u a g e , A rtif ic ial N e u ra l N e tw o rk s , T ra in in g D e e p N e tw o r k s , Im p r o vin g
D e e p N e tw o rk s .
lO M oAR cPSD |270 42294

Computer Vision Introduction

It is o n e o f th e m o s t c o m p e lling ty p e s o f a rtific ia l in te llig e n c e th a t w e re g u la rly


im p lem en t in o u r d a ily ro u tin e s .

C o m p u te r vis io n h elp s to u nd e rs ta n d th e c o m p le x ity o f th e h u m a n vis io n s ys tem a n d


tra ins c o m p u te r s ys te m s to in te rp re t a n d g a in a h ig h - le v e l u n d e rs ta n d in g o f d ig ita l
im a g e s o r v id e o s . In th e e a rly d a ys , d e v e lo p in g a m a c h in e s ys te m h a v in g
h u m a n - lik e in te llig e nc e w a s ju s t a d re a m , b u t w ith th e a d v a nc e m e n t o f a rtific ia l
in te llig e nc e a n d m a c h in e le a rn in g , it als o b e c a m e p o s s ib le . S im ila rly , s u c h in te llig e n t
s ys te m s h a v e b e e n d e ve lo p e d th a t c a n " s e e " a n d in te rp r e t th e w o rld a ro u n d th e m ,
s im ila r to h u m a n e y e s . T h e fic tio n o f ye s te rd a y h a s b e c o m e th e f a c t o f to d a y.

F u rth e r, A rtific ia l in te llig e n c e is th e b ra n c h o f c o m p u te r s c ie n c e th a t p rim a rily d e a ls


w ith c re a ting a s m a rt a n d in te llig e n t s y s te m th a t c a n b e h a ve a nd th in k lik e the
h u m a n b ra in . S o , w e c a n s a y if a rtific ia l in te llig e n c e e n a b le s c o m p u te r s ys te m s to
th in k in te llig e n tly , c o m p u te r v is io n m a k e s th e m c a p a b le o f s e e in g , a n a ly zin g , a n d
u n d e rs tan d in g .

H is to ry o f C o m p u te r V is io n

C o m p u te r vis io n is n o t a n ew te c h n o lo g y b e c a u s e s c ie n tis ts a n d e x p e rts h a ve b e e n


try in g to d e ve lo p m a c h in e s th at c a n s e e a n d un d e rs ta n d v is u a l d a ta f o r a lm o s t s ix
d e c a d e s . T h e e vo lutio n o f c o m p u te r vis io n is c la s s if ie d a s fo llo w s :

o 1959: T h e f irs t e x p e rim e n t w ith c o m p u te r vis io n w a s in itia ted in 1 9 59 , w h e re


th e y s h o w e d a c a t a s a n a r ra y o f im a g e s . In itia lly, th e y fo un d th a t the s ys te m
re a c ts firs t to h a rd ed g e s o r lin e s , a n d s c ie n tific a lly, th is m e an s th at im a g e
p ro c es s in g b e g in s w ith s im p le s ha p e s s u c h a s s tra ig h t e d g e s .
o 1960: In 19 6 0 , a rtific ia l inte llig e n c e w a s a d d e d a s a fie ld o f a c a d e m ic s tu d y to
s o lv e h u m a n v is io n p ro b le m s .
o 1963: T h is w a s an o th e r g r ea t a c h ie v e m e nt fo r s c ie n tis ts w h e n th e y d e ve lo p e d
c o m p u ter s th a t c o u ld tra n s fo rm 2 D im a g e s in to 3 - D im a g e s .
o 1974: T h is ye a r, o p tic a l c h a ra c te r re c o g nitio n (O C R ) a n d in te llig e n t c h a ra c te r
re c o g n itio n (IC R ) te c h n o lo g ie s w e re s u c c e s s fu lly d is c o v e re d . T h e O C R h a s
s o lv e d th e p ro b le m o f re c o g n izin g te x t p rin te d in a n y fo n t o r typ e f ac e ,
w h e re a s IC R c a n d e c ry p t ha n d w r itte n te x t. T h e s e in v e n tio n s a r e o n e o f th e
g re a te s t a c h ie v e m e n ts in d o c u m e n t a n d in vo ic e p ro c es s in g , v e h ic le n u m b e r
lO M oAR cPSD |270 42294

p la te re c o g nitio n , m o b ile p a ym e n ts , m a c h in e tr a ns la tio n , e tc .


o 1982: In th is y e a r, th e a lg o r ith m w a s d e v e lo p e d to d e te c t e d g es , c o rn e rs ,
c ur ve s , a n d o th e r s ha p e s . F u rth e r, s c ie ntis ts a ls o d e v e lo p e d a n e tw o rk o f
c ells tha t c o u ld re c o g n ize p a tte rn s .
o 2000: In th is y ea r , s c ie n tis ts w o rk e d o n a s tu d y o f o b je c t re c o g n itio n .
o 2001: T h e firs t r ea l- tim e fa c e re c o g n itio n a p p lic a tio n w a s d e ve lo p e d .
lO M oAR cPSD |270 42294

o 2010: T h e Im a g e N e t d a ta s e t b e c a m e a v a ila b le to u s e w ith m illio n s o f ta g g e d


im a g e s , w h ic h c an b e c o n s id e r ed th e fo u n d a tio n fo r re c e n t C o n vo lu tio n a l
N e u ra l N etw o rk ( C N N ) a n d d e e p le a rn in g m o d e ls .
o 2012: C N N h a s b e e n u s e d a s a n im a g e re c o g n itio n te c h n o lo g y w ith a re d u c e d
e rro r ra te .
o 2014: C O C O ha s a ls o b e e n d e ve lo p e d to o ffe r a d a ta s e t f o r o b je c t d ete c tio n
a n d s u p p o rt f utu re re s e a rc h .

How does Computer Vision Work?

C o m p u te r v is io n is a te c hn iq u e th a t e x tra c ts in fo rm a tio n fr o m v is u a l d a ta , s u c h a s
im a g e s a n d v id e o s . A lth o u g h c o m p u te r v is io n w o r k s s im ila rly to h u m a n e ye s w ith
b r ain w o rk , th is is p ro b a b ly o n e o f th e b ig g e s t o p en q u e s tio n s fo r IT p ro fe s s io n a ls :
H o w d o e s th e h u m a n b ra in o p e ra te a n d s o lve vis u a l o b je c t re c o g n itio n ?

O n a c e rta in le v e l, c o m p u te r v is io n is a ll a b o u t p a tte rn re c o g nitio n w h ic h inc lu d e s th e


tra inin g p ro c e s s o f m a c h in e s y s te m s fo r u n d e rs ta n d in g th e v is u a l d a ta s uc h a s
im a g e s a nd vid e o s , e tc .

F irs tly, a va s t a m o u n t o f vis u al lab e led d a ta is p r o vid e d to m a c h ine s to tra in it. T h is


la b e le d d ata e na b les th e m a c h in e to a n a lyz e d if fe re n t p a tter n s in a ll th e d a ta p o in ts
a n d c a n re la te to th o s e la b e ls . E .g ., s u p p o s e w e p ro v id e v is u a l d a ta o f m illio n s o f
d o g im a g e s . In th a t c a s e , th e c o m p u te r le a rn s fr o m th is d ata , a n a lyz e s ea c h p h o to ,
s h a p e , th e d is ta n c e b e tw e e n e a c h s h a p e , c o lo r, etc ., a nd h e n c e id e n tifie s p a tte rn s
s im ila r to d o g s a n d g e n e ra te s a m o d e l. A s a re s u lt, th is c o m p u te r vis io n m o d e l c a n
lO M oAR cPSD |270 42294

n o w a c c u ra te ly d e te c t w h e th e r th e im a g e c o n ta in s a d o g o r n o t fo r ea c h in p ut im a g e
lO M oAR cPSD |270 42294

Task Associated with Computer Vision

A lth o u g h c o m p u te r v is io n h a s b e e n u tilize d in s o m an y f ie ld s , th e re a re a fe w
c o m m o n ta s k s fo r c o m p u te r vis io n s y s te m s . T h e s e ta s k s a re g ive n b e lo w :

o Object classification is a c o m p ute r v is io n tec h n iq u e /tas k u s e d to c la s s ify a n


im a g e , s u c h a s w h e th e r a n im a g e c o n ta in s a d o g , a p er s o n 's fa c e , o r a
b an a n a . It a n a lyz e s th e v is u a l c o n te n t (v id eo s & im a g e s ) a n d c la s s ifie s th e
o b je c t in to th e d e fin e d c a te g o r y. It m e a ns th a t w e c a n a c c u ra te ly predict the
class of an object present in an image with image classification.
o Object Identification/detection: O b je c t id e n tif ic a tio n o r d e te c tio n u s e s im a g e
c la s s ific a tio n to id e n tify a n d lo c a te th e o b je c ts in a n im ag e o r vid e o . W ith s u c h
d ete c tio n a nd id e n tific a tio n te c hn iq u e , the s y s te m c a n c o u n t o b je c ts in a
g ive n im a g e o r s c e n e a n d d e te rm in e th e ir a c c u r ate lo c a tio n a n d la b e lin g . F o r
e x a m p le , in a g ive n im a g e , o n e d o g , o n e c a t, a n d o n e d u c k c a n b e e a s ily
d ete c te d a n d c la s s ifie d u s in g th e o b je c t d e te c tio n te c h n iq u e .
o Object Verification: T h e s y s te m p ro c e s s e s v id e o s , fin d s th e o b je c ts b a s e d o n
s e a rc h c rite ria , a n d tra c k s th e ir m o v e m e n t.
o Object Landmark Detection: T h e s ys te m d ef in e s th e k e y p o ints f o r th e g iv e n
o b je c t in th e im a g e d a ta .
o Image Segmentation: Im a g e s e g m e n ta tio n n o t o n ly d e te c ts th e c la s s e s in a n
im a g e a s im a g e c la s s ific a tio n ; in s te a d , it c la s s ifie s e ac h p ix e l o f a n im a g e to
s p ec ify w h a t o b je c ts it h a s . It trie s to d e te rm in e th e ro le o f e a c h p ix e l in th e
im a g e .
o Object Recognition: In th is , th e s ys te m re c o g n ize s th e o b je c t's lo c a tio n w ith
lO M oAR cPSD |270 42294

re s p e c t to the im a g e .
lO M oAR cPSD |270 42294

Applications of computer vision

B e lo w a r e s o m e m o s t p o p u la r ap p lic a tio ns o f c o m p ute r v is io n :

o Facial recognition: C o m p u te r v is io n h a s e n a b le d m a c h in e s to d e te c t fa c e
im a g e s o f p e o p le to v e rify th e ir id en tity . In itia lly , th e m a c h in e s a re g ive n in p u t
d ata im a g e s in w h ic h c o m p u te r vis io n a lg o rith m s d e te c t fa c ial fe a tu re s a n d
c o m p a r e th e m w ith d a ta b a s es o f fa k e p ro f ile s . P o p u la r s o c ia l m e d ia p la tf o rm s
lik e F a c e b o o k a ls o u s e fa c ial r e c o g n itio n to d e te c t a n d ta g u s e rs . F u rth e r,
v a rio u s g o v e rn m e n t s p y ag e n c ie s a re e m p lo yin g th is fe a tu re to id e n tify
c rim in a ls in vid e o fe e d s .
o Healthcare and Medicine: C o m p u ter vis io n h as p la ye d a n im p o r ta n t ro le in the
h e a lth c a re and m e d ic in e in d u s try . T ra d itio na l a p p r o a c h e s fo r e va lu a tin g
c an c e ro u s tu m o rs ar e tim e - c o n s u m in g a n d h a v e le s s ac c u ra te p re d ic tio n s ,
w h e re a s c o m p ute r v is io n tec h n o lo g y p r o vid e s fa s te r a n d m o re a c c u ra te
c he m o th e ra p y re s p o n s e a s s e s s m e n ts ; d o c to rs c a n id e n tify c a n c e r p a tie n ts
w h o n e e d f a s te r s u rg er y w ith life - s a vin g p re c is io n .
o Self-driving vehicles: C o m p u te r vis io n te c h n o lo g y h a s a ls o c o n trib u te d to its
ro le in s e lf - d rivin g ve h ic le s to m a k e s e n s e o f th e ir s u rro u n d in g s b y c a p tu rin g
v id e o fro m d iffe re n t an g les a r o u n d th e c a r a nd th e n in tro d u c in g it in to th e
s o ftw ar e . T h is h e lp s to d e te c t o the r c a rs a n d o b je c ts , re a d tra ff ic s ig n a ls ,
p ed e s tria n p a th s , e tc . , a nd s a fe ly d riv e its p a s s e n g e rs to th e ir d e s tin a tio n .
o Optical character recognition (OCR)
O p tic a l c h a ra c te r r ec o g n itio n h e lp s u s e x tr ac t p rinte d o r h a n d w ritte n te x t fro m
v is u a l d a ta s u c h a s im a g e s . F u rth e r, it a ls o e n a b le s u s to e x tra c t te x t fro m
d o c u m e n ts lik e in v o ic e s , b ills , a rtic le s , e tc .
o Machine inspection: C o m p u te r v is io n is vita l in p ro vid in g a n im a g e - b a s e d
a u to m a tic ins p e c tio n . It d e te c ts a m a c h in e 's d e fe c ts , fe a tu re s , an d fu n c tio n a l
fla w s , d e te rm in e s in s p e c tio n g o a ls , c h o o s e s lig h tin g a n d m a te ria l- h a n d lin g
te c h n iq u e s , a n d o th e r irre g ula ritie s in m a n u fa c tu re d p ro d u c ts .
o Retail (e.g., automated checkouts): C o m p u te r vis io n is a ls o b e in g
im p le m e n te d in th e re ta il ind u s trie s to tra c k p ro d u c ts , s h e lve s , w a g e s , re c o rd
p ro d u c t m o ve m e n ts in to th e s to re , e tc . T h is A I- b a s e d c o m p u te r v is io n
te c h n iq u e a u to m a tic a lly c h a rg e s th e c u s to m e r fo r th e m a rk e d p ro d u c ts u p o n
c he c k o u t fro m th e re ta il s to re s .
o 3D model building: 3 D m o d e l b u ild in g o r 3 D m o d eling is a te c h n iq u e to
g en e ra te a 3 D d ig ita l re p re s e n ta tio n o f a n y o b je c t o r s u rfa c e u s in g the
s o ftw ar e . In th is field a ls o , c o m p u te r v is io n p la y s its ro le in c o n s tru c tin g 3 D
c o m p u ter m o d e ls fr o m e x is tin g o b je c ts . F u rth er m o re , 3 D m o d e lin g ha s a
v a rie ty o f a p p lic atio n s in va rio u s p la c e s , s u c h a s R o b o tic s , A u to n o m o u s
d rivin g , 3 D tra c k in g , 3 D s c e n e re c o n s tru c tio n , an d A R /V R .
lO M oAR cPSD |270 42294

o Medical imaging: C o m p u te r vis io n h e lp s m e d ic a l p ro fe s s io n a ls m a k e b e tte r


d ec is io n s re g a r d in g tre a tin g p a tie nts b y d e v e lo p in g vis u aliza tio n o f s p e c ific
b o d y p a rts s u c h a s o rg a n s a n d tis s u e s . It h e lp s th e m g e t m o re a c c u ra te
d ia g n o s e s a n d a b e tte r p a tie n t c a re s ys te m . E .g ., C o m p u te d T o m o g ra p h y
( C T ) o r M a g n e tic R e s o n a n c e Im a g in g (M R I) s c a n n e r to d ia g n o s e p a th o lo g ie s
o r g u id e m e d ic a l in te rve n tio n s s u c h a s s u rg ic a l p la n n in g o r fo r re s e a rc h
p ur p o s e s .
lO M oAR cPSD |270 42294

o Automotive safety: C o m p ute r vis io n h a s a d d e d a n im p o rta nt s a fe ty fe a tu re in


a u to m o tiv e in d u s trie s . E .g . , if a v e h ic le is ta u g h t to d e te c t o b je c ts a n d d an g e rs ,
it c o uld p r ev e n t a n ac c id e n t a n d s av e th o u s a nd s o f live s a n d p ro p e rty.
o Surveillance: It is o n e o f c o m p u te r vis io n tec h n o lo g y's m o s t im p o rta n t a n d
b e n e fic ia l u s e c a s e s . N o w a d a ys , C C T V c a m e ra s a re a lm o s t fitte d in e v e ry
p la c e , s u c h a s s tre e ts , ro a d s , h ig h w a ys , s h o p s , s to re s , e tc ., to s p o t v ar io u s
d o ub tfu l o r c rim in a l a c tiv itie s . It h e lp s p ro v id e live fo o ta g e o f p u b lic p la c e s to
id e n tify s u s p ic io u s b e h a vio r, id e n tify d a ng e ro u s o b je c ts , a n d p re ve n t c rim e s
b y m a in ta in in g la w an d o rd e r.
o Fingerprint recognition and biometrics: C o m p u te r v is io n te c h n o lo g y d e te c ts
fin g er p rin ts a n d b io m e tric s to v a lid a te a u s e r's id e n tity. B io m e tric s d e a ls w ith
re c o g n iz in g p e rs o n s b a s e d o n p h y s io lo g ic a l c h a ra c te ris tic s , s u c h a s th e f a c e ,
fin g er p rin t, va s c u la r p a tte rn , o r iris , a n d b e h a vio ra l tr aits , s u c h a s g a it o r
s p e e c h . It c o m b in e s C o m p u te r V is io n w ith k n o w le d g e o f h u m a n p h y s io lo g y
a n d b e h a vio r.

Human and Machine Language

H u m a n la n g u ag e is a c o m p lex a n d d yn a m ic s ys te m o f c o m m u n ic a tio n u s e d b y
h um an s to e x p re s s th o u g h ts , id e a s , a n d e m o tio n s . H u m a n la n g u a g e s e x is t in th re e
fie ld s – s p e e c h ,

H u m a n la ng u a g e is a c o m p le x a n d s o p h is tic a te d s ys te m o f c o m m u n ic a tio n us e d b y
h um an s to c o n v e y th o u g h ts , id e a s , e m o tio n s , an d in fo rm a tio n . It is o n e o f th e
d e fin in g c h a ra c te ris tic s o f o ur s p e c ie s a n d p la y s a c e n tr a l r o le in o ur a b ility to
c o m m u nic a te , le a rn , a n d in te ra c t w ith o n e an o th e r.

Key features of human language include:


1 . Arbitrariness: T h e re is n o in h e re n t c o n n e c tio n b e tw e e n th e w o rd s u s e d in a
la n g u a g e a n d th e
o b je c ts , a c tio n s , o r id e a s th e y re p re s e n t. F o r e x a m p le , th e re 's n o th in g ab o u t th e
w o rd " d o g " th a t
in h e re n tly re la te s it to th e fu rry, fo u r- le g g e d a n im al it s ig nifie s .
2 . Productivity: H u m a n la n g u a g e is h ig hly c re a tive a n d a llo w s s p ea k e rs to g e n e ra te
a n in fin ite
n um b e r o f n e w s e n te n c e s to c o n ve y n e w id ea s . T h is is a c h ie v e d th ro u g h th e
c o m b in a tio n o f
w o rd s a n d g ra m m a tic a l ru le s .
3 . Discreteness: L a n g u a g e is c o m p o s e d o f d is c re te u n its , s u c h a s in d ivid u a l s o u nd s
(p h o n e m e s ),
w o rd s , a n d g ra m m a tic a l e le m e n ts ( m o rp h e m e s a n d s y n ta x ). T h e s e u n its c a n b e
c o m b in e d to
c re a te m e a n in g fu l c o m m u nic a tio n .
4 . Duality of Patterning : L a n g u a g e h a s a h ie r ar c h ic a l s tru c tu re , w ith s m all
m e a nin g fu l un its
(m o rp h e m e s ) c o m b in e d in to la rg e r u n its ( w o rd s ) a n d th en into s e n te n c e s . A t e a c h
lO M oAR cPSD |270 42294

le v e l, th er e is a
d is tin c t p a tter n o f o rg a n iza tio n .
5 . Semanticity: L a n g u a g e c o n ve y s m e a n in g th ro u g h w o rd s a n d th e w a y the y a re
a rra n g e d in
s e nte n c e s . W o rd s h a ve s p e c ific m e a nin g s , a n d th e c o m b in a tio n o f w o r d s in a
s e nte n c e c a n c r e ate
c o m p le x m ea n ing s .
6 . Cultural Transmission: L a n g u a g e is le a rn e d a n d tra n s m itte d fro m o n e g e n e ra tio n to
th e n ex t
th ro u g h c u ltu ra l an d s o c ia l inte ra c tio n s . C h ild re n a c q u ire la n g u a g e b y
e x p o s u re to th e
la n g u a g e (s ) s p o k e n in th e ir e n v iro n m e n t.
lO M oAR cPSD |270 42294

7 . Multimodality: W h ile sp oken la ng u a g e is th e m ost c om m o n fo rm , hum an


c o m m u n ic atio n is m u ltim o d a l, m e a n in g it c a n in v o lve va rio u s m o d e s lik e w ritin g ,
s ig n la ng u a g e , a n d e v e n n o n - ve rb a l e le m e n ts lik e g e s tu re s a n d fa c ia l e x p r es s io n s .
8 . Recursion: H u m a n la n g u a g e s c a n e m b e d o n e s tru c tu re w ith in a n o th e r, a llo w in g fo r
c o m p le x s e n te n c e s tr u c tu re s . T h is re c u rs iv e fe a tu r e e n ab le s th e c re a tio n o f in tric a te
a n d la y e re d m e an in g s .
9 . Symbolism: La n g u a g e u s e s s y m b o ls ( w o rd s ) to re p re s e n t id e a s , o b jec ts , a n d
c o n c e p ts . T h is s y m b o lic n a tu re a llo w s fo r a b s tra c t a n d im a g in a tive thin k in g .
1 0 . Pragmatics: L a n g u a g e is n o t ju s t a b o u t w o rd s a n d g ra m m a r; it a ls o in v o lv es th e
s o c ia l a n d c o n te x tu a l a s p e c ts o f c o m m un ic a tio n . P ra g m a tic s d e als w ith h o w
la n g u a g e is u s e d in d iffe re n t s o c ia l a n d c ultu r al s e ttin g s a n d h o w m e a nin g c a n
c h a n g e b a s e d o n c o n te x t.

Hum an lan g u a g e is in c re d ib ly d iv er s e , w ith th o u s a n d s o f la n g u a g e s s p o k e n


w o rld w id e , e a c h w ith its o w n un iq u e fe a tur e s , g ra m m a r, an d v o c ab u lar y. It's a
d y n a m ic a n d e v o lvin g s y s te m th a t a d a p ts to th e c h a n g in g ne e d s a n d c u ltu re s o f th e
s p e a k e rs . S tu d yin g h u m a n la n g u a g e is a c o m p lex fie ld k n o w n a s lin g uis tic s , w h ic h
s e e k s to u n d e rs ta n d th e s tr uc tu re , e vo lu tio n , a n d u s e o f la ng u a g e in h u m a n s o c ie ty.

M a ch ine la ng u a g e

M a c h in e la ng u a g e , o fte n re fe rr ed to a s m ac h in e c o d e, is a lo w - le ve l p ro g ra m m in g
la n g u a g e th a t is d ire c tly un d e rs to o d and ex e c u te d by a c o m p u ter 's c e n tra l
p r o c e s s in g u n it (C P U ) . It is th e lo w e s t- le v e l re p re s e n ta tio n o f a p r o g r a m a n d is
co m po se d o f b in a ry d ig its (0 s a n d 1s ) th a t c o rre s p o n d to s p e c ific m a c h in e
in s tr uc tio n s .

K e y c h a ra c te ris tic s o f m a c h in e la n g ua g e in c lu d e :

1. Binary Representation: M a c h in e la n g u a g e in s tru c tio n s a re re p re s e n te d u s in g b in a ry


c o d e , w he r e e a c h in s tru c tio n is a s e q u e n c e o f 0 s a n d 1s . E ac h c o m b in a tio n o f 0 s
a n d 1 s c o rre s p o n d s to a s p e c ific o p e ra tio n o r c o m m a n d th a t th e c o m p u te r's C P U
c a n p er fo rm .
2 . Machine-Specific : M a c h in e la n g u a g e is tie d to th e ar c h ite c tu re a n d in s tru c tio n s e t o f
a p a rtic u la r c o m p u te r o r p ro c e s s o r. D iffe re n t ty p e s o f C P U s h a ve th e ir o w n u niq u e
m a c h in e la n g u a g e s , s o p ro g ra m s w ritte n in m a c h in e c o d e a re n o t p o r ta b le b e tw e e n
d iffe re n t ty p e s o f c o m p u ter s .
3 . Low-Level: M a c h ine la n g ua g e is a lo w - le ve l p ro g ra m m in g la n g u a g e b e c a u s e it
d ire c tly c o rre s p o n d s to th e h a rd w a re o f th e c o m p u te r. E a c h in s tru c tio n typ ic ally
c o rre s p o n d s to a s p e c ific h a rd w a re o p e ra tio n , s u c h a s m o v in g d a ta b e tw e e n
re g is te rs , p e rfo rm in g a rith m e tic c alc u la tio n s , o r b ra n c h in g to a d iffe re n t p a r t o f th e
p r o g r am .
lO M oAR cPSD |270 42294

4 . Difficult for Humans: W r itin g p ro g ra m s d ire c tly in m a c h in e la n g u a g e is ex tre m e ly


c u m b e rs o m e a n d e rro r- p r o n e fo r h u m a n s . It re q u ire s a d e e p u n d e rs ta n d in g o f th e
c o m p u te r 's a rc h itec tu re a n d is n o t p r ac tic a l fo r m o s t p ro g ra m m ing ta s k s .
5 . No Abstraction: M a c h in e la n g u ag e la c k s th e h ig h - lev e l a b s tra c tio n s a nd fe a tu re s
fo un d in h ig h e r- le ve l p ro g ra m m in g la ng u a g e s lik e C + + , J a va , o r P y th o n . T he r e a re
n o va r ia b le s , f un c tio n s , o r d a ta s tru c tu re s in m a c h in e la n g u a g e ; in s te a d , ev e ryth in g
is re p re s e n te d a s s e q u e n c e s o f b in ar y in s tr u c tio n s .
6 . Assembler : To m ake p ro g ra m m in g in m a c h in e la n g u a g e m o re m a n a g e a b le ,
a s s e m b ly la n g u a g e w a s d e v e lo p e d . A s s e m b ly la n g u a g e is a h u m a n - re a d ab le
re p r e s en ta tio n o f m a c h in e c o d e th a t
lO M oAR cPSD |270 42294

u s es m n e m o nic s a n d s ym b o lic n am es fo r in s tru c tio n s a n d m e m o ry a d d re s s e s .


A s s e m b ly c o d e is th e n tra n s la te d in to m a c hin e c o d e u s in g a n a s s e m b le r.

D e s p ite its c ha lle n g e s a nd lim ita tio n s , m a c h in e la ng u a g e is fu n d a m e nta l to th e


o p e r atio n o f c o m p u te rs . A ll h ig h e r- le v e l p ro g ra m m in g la n g u a g e s u ltim ate ly c o m p ile
o r in te rp re t th e ir c o d e in to m ac h in e c o d e b e fo re it c an b e e x e c u te d b y a c o m p u te r's
CP U . M o d e rn c o m p u te r s y s te m s us e c o m p le x c o m p ile rs a n d in te rp re te rs to
tra n s la te hig h - le ve l co de in to m a c h in e cod e , m a k ing it m uch e a s ie r fo r
p ro g ra m m e rs to d e ve lo p s o ftw a re w ith o u t n e ed in g to w o rk d ire c tly w ith m ac h in e
la n g u a g e .
Natural Language Processing
N a tu ra l La n g u a g e P ro c e s s in g ( N L P ) is a fie ld o f A rtific ia l Inte llig e n c e (A I) a n d
C o m p u te r S c ie n c e th at is c o n c e rn e d w ith th e in te ra c tio n s b e tw e e n c o m p u te rs a n d
h um an s in n a tu r al la n g u a g e . T h e g o a l o f N L P is to d e ve lo p a lg o rithm s a n d m o d e ls
th a t e n a b le c o m p u te rs to u n d e rs ta n d , in ter p re t, g e n e ra te , a n d m a n ip u la te h u m a n
la n g u a g e s .
lO M oAR cPSD |270 42294
lO M oAR cPSD |270 42294

N a tu ra l la n g u a g e p ro c e s s in g ( N L P ) is a s u b fie ld o f A rtific ia l In te llig e n c e ( A I) . T h is is a


w id e ly u s e d tec h n o lo g y fo r p e rs o n a l a s s is ta n ts th a t a r e u s e d in va rio u s b us in e s s
fie ld s /a re a s . T h is te c h n o lo g y w o rk s o n th e s p e e c h p ro v id ed b y th e u s e r b re a k s it
d o w n fo r p ro p e r u nd e rs ta n d in g a n d p r o c e s s e s it ac c o rd ing ly. T h is is a ve ry re c en t
a n d e ffe c tive a p p ro a c h d u e to w h ic h it h a s a re a lly h ig h d e m a n d in to d a y’ s m a rk e t.
N a tu ra l L a n g u a g e P ro c e s s in g is a n u p c o m in g field w h e re a lre a d y m a n y tra n s itio n s
s u c h a s c o m p a tib ility w ith s m a rt d e v ic e s , a n d in te ra c tive ta lk s w ith a h u m a n h a v e
b e e n m a d e p o s s ib le . K n o w le d g e re p re s e n ta tio n , lo g ic a l re a s o n in g , a n d c o n s tra in t
s a tis f ac tio n w e re th e e m p h a s is o f A I a p p lic a tio n s in N L P . H e r e fir s t it w a s a p p lie d to
s e m a n tic s a n d la te r to g ra m m a r. In th e la s t d e c a d e , a s ig nific a nt c h a n g e in N L P
re s e a rc h h a s re s u lte d in th e w id e s p re a d u s e o f s ta tis tic a l a p p r o a c h e s s u c h a s
m a c h in e le a rn in g a nd d a ta m in in g o n a m a s s iv e s c a le. T h e n ee d fo r a u to m a tio n is
n e ve r- e n d in g c o u rte s y o f th e a m o u n t o f w o rk re q u ire d to b e d o ne th e s e d ay s . N L P
is a v e ry fa v o ra b le , b u t a s p e c t w h e n it c o m e s to a u to m ate d ap p lic a tio n s . T h e
a p p lic a tio n s o f N L P h a v e le d it to b e o ne o f th e m o s t s o u g ht- a fte r m e th o d s o f
im p lem en tin g m a c h in e lea r nin g . N a tu ra l L a n g u ag e P ro c e s s in g (N L P ) is a fie ld tha t
c o m b in es c o m p u te r s c ie n c e , lin g u is tic s , a n d m a c h ine le ar n in g to s tud y how
c o m p u te r s an d h u m a n s c o m m u nic a te in n a tu r al la n g u a g e. T h e g o a l o f N L P is fo r
c o m p u te r s to b e a b le to in te rp re t a n d g e n e ra te h u m a n lan g u a g e . T h is n o t o n ly
im p ro v e s th e e ffic ie n c y o f w o rk d o n e b y h u m a ns b u t a ls o h e lp s in in te ra c tin g w ith
th e m a c h in e . N L P b rid g e s th e g a p o f in te ra c tio n b e tw ee n h u m a n s a n d e le c tr o n ic
d e v ic es .

N a tu ra l L a n g u a g e P ro c e s s in g (N L P ) is a s u b f ie ld o f a rtific ia l in te llig e n c e th a t d e a ls
w ith th e in te ra c tio n b e tw e e n c o m p u te rs a n d h u m a n s in n a tu ra l la ng u a g e . It
in v o lve s th e us e o f c o m p u ta tio n a l te c h n iq u e s to p ro c e s s a n d a n a lyz e n a tu ra l
la n g u a g e d a ta , s u c h as te x t a n d s p e e c h , w ith th e g o a l o f u n d e rs ta n d in g th e
m e a n in g b e h in d th e la n g u a g e .

N L P is u s e d in a w id e ra n g e o f a p p lic a tio n s , in c lu d in g m a c hin e tra n s la tio n , s e n tim e n t


a n a lys is , s p e e c h re c o g n itio n, c h a tb o ts , a n d te x t c la s s if ic a tio n .

S o m e c o m m o n te c h niq u e s u s e d in N L P in c lu d e :

1 . Tokenization: th e p ro c e s s o f b re a k in g te x t in to in d ivid u a l w o rd s o r p h ra s e s .
2 . Part-of-speech tagging: th e p ro c e s s o f la b e lin g e a c h w o rd in a
s e n te n c e w ith its g ra m m a tic a l p a rt o f s p e ec h .
3 . Named entity recognition: th e p r o c e s s o f id e n tify in g a n d c a te g o riz in g n a m e d
e n titie s , s u c h a s p e o p le , p la c e s , a n d o rg an iza tio n s , in te x t.
4 . Sentiment analysis: th e p ro c e s s o f d e te rm in in g th e s e n tim e nt o f a p ie c e o f
te x t, s u c h a s w h e th e r it is p o s itive , n e g a tive , o r n e utra l.
5 . Machine translation: th e p ro c e s s o f a u to m atic a lly tr an s la tin g te x t f ro m o n e
la n g u a g e to a n o th e r.
6 . Text classification: th e p ro c e s s o f c ate g o r izing te x t in to p re d e fin e d c a te g o rie s o r
to p ic s .
lO M oAR cPSD |270 42294

R e c e n t a d va n c e s in d e e p lea r nin g , p ar tic ula rly in th e a re a o f n e u ra l n e tw o rk s , h a v e


le d to s ig n ific a n t im p r o ve m e n ts in th e p e rfo rm a n c e of N LP s y s te m s . Deep
le a rn in g te c h niq u e s s u c h a s C o n v o lu tio n al N e u ra l N e tw o rk s (C N N s ) a nd R e c u rr en t
N e u ra l N e tw o r k s (R N N s ) h a v e b e e n a p p lie d to ta s k s s u c h a s s e n tim e n t a n a lys is a n d
m a c h in e tra n s la tio n, a c h ie vin g s ta te- o f- th e - a rt re s u lts .

O v e ra ll, N L P is a ra p id ly e vo lv in g fie ld th a t h a s the p o te n tia l to re vo lu tio n ize th e w a y


w e in te ra c t w ith c o m p u te rs a n d th e w o rld a ro u n d u s .
lO M oAR cPSD |270 42294

Common Natural Language Processing (NLP) Task:

● Text and speech processing: T h is in c lu d e s S p e e c h re c o g nitio n ,


te x t- & - s p e e c h p ro c e s s in g , e n c o d in g ( i.e c o n v er tin g s p e e c h o r te x t to
m a c h in e- r e ad a b le la n g u a g e ), e tc .
● Text classification: T h is inc lu d e s S e n tim e n t A n a ly s is in w h ic h th e m a c h in e c a n
a n a lyz e th e q u a lities , e m o tio n s , a n d s a rc a s m f ro m te x t a n d a ls o c la s s ify it
a c c o rd in g ly .
● Language generation: T h is in c lu d e s ta s k s s u c h a s m a c h in e tr a ns la tio n ,
s u m m a ry w ritin g ,e s s a y w ritin g , e tc . w h ic h a im to p ro d u c e c o h e re n t a n d flu e n t
te x t.
● Language interaction: T h is in c lu d e s ta s k s s uc h a s d ia lo g u e s ys te m s , vo ic e
a s s is ta n ts , a n d c h atb o ts , w h ic h a im to e n a b le n a tu ra l c o m m u n ic a tio n b e tw e en
h u m a n s a n d c o m p ute rs .

N L P te c h n iq u e s a re w id e ly u s e d in a va rie ty o f a p p lic a tio n s s u c h a s s e a rc h e ng in e s ,


m a c h in e tra n s la tio n , s e n tim e nt a n aly s is , te x t s u m m a riza tio n , q u e s tio n a n s w e rin g ,
a n d m a n y m o re . N L P re s e a rc h is a n a c tiv e fie ld a n d re c e n t a d v a n c e m e n ts in d e e p
le a rn in g h a v e le d to s ig n ific a n t im p ro v e m e n ts in N L P p e rfo rm a n c e . H o w e ve r, N L P is
s till a c h a lle n g in g fie ld a s it re q u ire s a n u n d e rs ta n d in g o f b o th c o m p u ta tio n al a n d
lin g u is tic p r in c ip le s .

Working of Natural Language Processing (NLP)

W o rk in g in n a tu ra l la n g u a g e p ro c e s s in g (N LP) typ ic a lly in v o lve s u s in g


c o m p u ta tio n a l te c h n iq u e s to an a ly ze a n d u nd e rs ta n d h u m a n la n g ua g e . T h is c a n
in c lu d e ta s k s s uc h a s la n g u ag e u n d e rs ta n d in g , la n g u a g e g e n e ra tio n , a n d la n g u a g e
in te ra c tio n .

T h e fie ld is d iv id e d in to th r ee d iffe re n t p a rts :

1 . Speech Recognition — T h e tra n s la tio n o f s p o k e n la n g u a g e in to te x t.


2 . Natural Language Understanding (NLU) — T h e c o m p u te r’ s a b ility to
u n d e rs tan d w h a t w e
s a y.
3 . Natural Language Generation (NLG) — T h e g e n e ra tio n o f n a tu ra l
la n g u a g e b y a
c o m p u te r .
N L U a n d N L G a re th e k e y a s p e c ts d e p ic tin g th e w o rk in g o f N L P d e vic e s . T h es e 2
a s p e c ts a re ve ry d iffe re n t fro m e a c h o th e r a n d a re a c h iev e d u s in g d iffe re n t m e th o d s .

Speech Recognition:
lO M oAR cPSD |270 42294

● F irs t, the c o m p u te r m ust ta k e n a tu ra l la n g u a g e and c o n ve r t it in to


m a c h in e- r e ad a b le la n g u a g e . T h is is w h a t s p e e c h r ec o g n itio n o r s p e e c h - to - te x t
d o e s . T h is is th e fir s t s te p o f N L U .
● H id d e n M a r k o v M o d els ( H M M s ) a r e us e d in th e m a jo r ity o f vo ic e re c o g n itio n
s ys te m s now a da y s. These a re s ta tis tic a l m o d e ls th a t use m a th e m a tic a l
c a lc u la tio n s to d ete rm in e w h a t y o u s a id in o rd e r to c o n v e rt yo u r s p e e c h to te x t.
● H M M s d o th is b y lis te n in g to y o u ta lk , b re a k in g it d o w n in to s m a ll u n its (ty p ic a lly
1 0 - 2 0 m illis e c o n d s ) , an d c o m p a rin g it to p re - re c o rd e d s p e e c h to fig u re o u t w h ic h
p h o n e m e y o u u tte re d in e a c h u n it ( a p h o n e m e is th e s m a lle s t u n it o f s p e e c h ) .
T h e p ro g ra m th e n e x a m in e s th e s eq u e n c e o f p h o n e m e s a n d u s e s s ta tis tic a l
a n a lys is to d e te rm in e th e m o s t lik e ly w o rd s a n d s e n te n c es y o u w e re s p e a k in g .

Natural Language Understanding (NLU):


T h e ne x t a n d h a rd e s t s tep o f N L P is th e u n d e rs ta n d in g p a rt.
lO M oAR cPSD |270 42294

● F irs t, th e c o m p u te r m u s t c o m p re h e n d th e m e a n in g o f e a c h w o r d . It tr ie s to f ig u re
o u t w h e th e r the w o rd is a n o u n o r a v e rb , w h e th e r it’ s in th e p a s t o r p re s e n t
te n s e , a n d s o o n . T h is is c a lle d P a rt- o f- S p e e c h ta g g in g ( P O S ) .
● A le x ic o n (a vo c a b u la ry ) an d a s e t o f g ra m m a tic a l ru le s a r e a ls o b u ilt in to N L P
s ys te m s . T he m o s t d iffic u lt p a rt o f N L P is u n d e rs ta n d in g .
● T h e m a c h ine s h o u ld b e a b le to g ra s p w h a t y o u s a id b y th e c o n c lu s io n o f th e
p r o c e s s . T he r e a re s e ve ra l c h a lle n g e s in ac c o m p lis h in g th is w h e n c o n s id er in g
p r o b le m s s u c h a s w o rd s h a v in g s e ve r al m e a n in g s ( p o ly s e m y) o r d if fe re n t w o rd s
h a vin g s im ila r m e a n in g s ( s yn o n ym y ), b u t d ev e lo p e r s e n c o d e ru le s in to th eir N L U
s ys te m s a n d tra in th e m to le a rn to a p p ly th e ru le s c o rre c tly.

Natural Language Generation (NLG):


N LG is m u ch s im p le r to a c c o m p lis h . N LG c o n v e rts a c o m p u te r’ s
m a c h in e- r e ad a b le la n g u ag e in to te x t a n d c a n a ls o c o n v e rt th a t te x t in to a u d ib le
s p e e c h u s in g tex t- to - s p ee c h te c h no lo g y .

● F irs t, th e N L P s ys te m id e n tifie s w h a t d a ta s h o u ld b e c o n v e rte d to te x t. If yo u a s k e d


th e c o m p u te r a q u es tio n ab o u t th e w ea the r , it m o s t lik e ly d id a n o n lin e s e a rc h to
fin d yo u r a n s w e r , a n d fro m th e re it d e c id e s th a t th e te m p e ra tu re , w in d , a n d
h u m id ity a re th e fa c to r s th a t s h o u ld b e re a d a lo u d to yo u .
● T h e n , it o rg a n iz e s th e s tru c tur e o f h o w it’ s g o in g to s a y it. T his is s im ila r to N L U
e x c e p t b a c k w a r d . N L G s y s te m c a n c o n s tru c t fu ll s e n te n c e s u s in g a lex ic o n a nd a
s e t o f g ra m m a r ru le s .
● F in a lly , te x t- to - s p e e c h ta k e s o v er . T h e tex t- to - s p e ec h e n g in e u s e s a p ro s o d y
m o d e l to e va lu a te th e te x t a n d id e n tify b re a k s , d u ra tio n , a n d p itc h. T h e e n g in e
th e n c o m b in e s a ll th e re c o rd e d p h o n e m e s in to o n e c o he s ive s trin g o f s p e e c h
u s in g a s p e e c h d a ta b a s e.

Applications of Natural Language Processing (NLP):


● Spam Filters: O n e o f th e m o s t irrita tin g th in g s a b o u t em ail is s p a m . G m a il u s e s
n a tu ra l la n g u a g e p r o c e s s in g ( N L P ) to d is c e rn w h ic h e m a ils a re le g itim a te a n d
w h ic h a re s p a m . T h es e s p a m filte rs lo o k a t th e te x t in a ll the e m a ils y o u re c e ive
a n d try to fig u re o u t w h a t itm e a n s to s e e if it’ s s p a m o r n o t.
● Algorithmic Trading: A lg o r ith m ic tr ad in g is u s e d fo r p re d ic tin g s to c k m a rk e t
c o n d itio n s . U s in g N LP , th is te c h no lo g y e x a m in e s n e w s h e a d line s a b o u t
c o m p a n ie s a n d s to c k s a n d atte m p ts to c o m p re h e n d th e ir m e a n in g in o rd e r to
d e ter m in e if yo u s h o u ld b u y , s e ll, o r h o ld c e rta in s to c k s .
● Questions Answering: N L P c a n b e s e e n in a c tio n b y u s in g G o o g le S ea r c h o r S iri
S e rv ic e s .A m a jo r u s e o f N L P is to m a k e s e a rc h e n g in e s u n d er s ta n d th e
m e a n in g o f w h a t w e a re a s k in g a n d g en e ra te na tur a l la n g u a g e in re tu rn to g ive
u s th e a n s w e rs .
● Summarizing Information: O n th e in te rn e t, th er e is a lo t o f inf o rm a tio n , a n d a lo t o f
lO M oAR cPSD |270 42294

it c o m e s in th e fo rm o f lo n g d o c u m e n ts o r a rtic le s . N L P is u s e d to d e c ip h e r th e
m e a n in g o f th e d a ta a n d th e n p ro v id e s s h o rte r s um m a rie s o f th e d a ta s o th a t
h u m a n s c a n c o m p r e he n d it m o re q u ic k ly .
lO M oAR cPSD |270 42294

What is Artificial Neural Network?

T h e te rm " Artificial Neural Network " is d e rive d fr o m B io lo g ic a l n e u ra l n etw o rk s th a t


d e v e lo p th e s tru c tu re o f a h um an b ra in . S im ila r to th e h u m a n b ra in th a t h as ne u ro n s
in te rc o n n e c te d to o n e a n o th e r, a rtific ia l n eu r al n e tw o rk s a ls o h a v e n e u ro ns th a t a re
in te rc o n n e c te d to o n e an o th e r in v ar io u s la y e rs o f the n e tw o r k s . T h e s e n e ur o n s a re
know n a s no des.

The given figure illustrates the typical diagram of Biological


Neural Network.

The typical Artificial Neural Network looks something like the given figure.
lO M oAR cPSD |270 42294
lO M oAR cPSD |270 42294

D e n d rite s f ro m B io lo g ic a l N e u ra l N e tw o rk re p re s e n t in p u ts in A rtif ic ia l N e u ra l
N e tw o rk s , c elln uc le u s re p re s e n ts N o d e s , s yn a p s e r e p re s e n ts W eig h ts , an d A x o n
re p re s e n ts O u tp u t.

R e la tio n s h ip b e tw e en B io lo g ic a l n e u ra l n etw o rk a n d a rtific ia l n e u ra l n e tw o rk :

Biological Neural Network Artificial Neural Network

D e n d rite s In p u ts

C e ll n u c le u s N o des

S yn a p s e W e ig h ts

A xon O u tp u t

A n Artificial Neural Network in th e f ie ld o f Artificial intelligence w h e re it a ttem p ts to


m im ic th e n e tw o rk o f n e u ro n s m a k e s u p a h u m a n b ra in s o th a t c o m p u te rs w ill h a v e
an o p tio n to u n d e rs ta n d th in g s a n d m a k e d e c is io n s in a h u m a n - lik e m a n n e r. T h e
ar tific ia l n e u ra l n e tw o rk is d e s ig n e d b y p ro g ra m m ing c o m p u te rs to b e h a v e s im p ly
lik e in te rc o nn e c te d b ra in c ells .

T h e re a re a ro u n d 10 0 0 b illio n n e u ro n s in th e h u m a n b ra in . E a c h n e u ro n ha s a n
as s o c iatio n p o in t s o m e w he r e in th e ra n g e o f 1 ,0 0 0 a n d 1 0 0 ,0 0 0 . In th e h u m a n b ra in ,
d a ta is s to re d in s u c h a m a n n er a s to b e d is trib u te d , an d w e c a n e x tra c t m o re th a n
o n e p ie c e o f th is d a ta w h e n n e c e s s a ry f ro m o u r m e m o ry p a ra lle lly . W e c a n s a y th a t
th e h u m a n b ra in is m a d e u p o f in c re d ib ly a m a z in g p a ra lle l p r o c e s s o rs .

W e c a n u n d e rs ta n d th e a rtific ia l n e u ra l n e tw o r k w ith a n e x a m p le , c o ns id e r a n
ex a m p le o f a d ig ita l lo g ic g a te th a t ta k e s a n in p ut a n d g iv e s a n o u tp u t. "O R " g a te ,
w h ic h ta k e s tw o in p u ts . If o ne o r b o th th e in p u ts a re " O n ," th en w e g e t " O n " in o u tp u t.
If b o th th e in p u ts a re "O f f," th e n w e g e t " O ff" in o u tp u t. H e re th e o u tp u t d e p e n d s
up o n in p ut. O u r b ra in d o e s n o t p er fo rm th e s a m e ta s k . T h e o u tp u ts to in p u ts
re la tio n s h ip k e e p c h a n g in g b e c a us e o f th e n e ur o n s in o u r b ra in , w h ic h a re " le a rn ing ."

The architecture of an artificial neural network:

T o u n d er s ta n d th e c o n c e p t o f th e a rc h ite c tu re o f a n a rtific ia l n e u ra l n e tw o rk , w e
ha v e to u n d e rs ta n d w h a t a n e u ra l n e tw o rk c o n s is ts o f. In o rd e r to d e fin e a n e u ra l
ne tw o rk th a t c o ns is ts o f a lar g e n u m b e r o f a rtific ia l n e u ro n s , w h ic h a re te rm ed u n its
ar ra n g e d in a s e q u e n c e o f la ye rs . L e ts u s lo o k a t v ar io u s typ e s o f la ye rs a v a ila b le in
an a rtific ia l n e u ra l n e tw o rk .
lO M oAR cPSD |270 42294

A rtif ic ia l N e u ra l N e tw o rk p rim a rily c o n s is ts o f th r ee la ye rs :


lO M oAR cPSD |270 42294

Input Layer:

A s th e n a m e s u g g e s ts , it a c c e p ts in p u ts in s e v e ra l d iff e re n t f o rm a ts p ro v id e d b y th e
p r o g r am m e r.

Hidden Layer:

T h e h id d e n la y er p re s e nts in- b e tw e en in p u t a n d o utp u t lay e rs . It p e rfo r m s a ll the


c a lc u la tio n s to fin d h id d e n fe a tu re s a n d p a tte r ns .

Output Layer:

T h e in p u t g o e s th ro u g h a s e rie s o f tra n s fo r m a tio n s u s in g th e h id d e n la y e r, w h ic h


fin a lly re s u lts in o u tp ut th a t is c o n v ey e d us in g th is la y e r.

T h e a rtific ia l n e ur a l n e tw o rk ta k e s in p u t a n d c o m p u te s th e w e ig hte d s u m o f th e
in p u ts a n d in c lu d es a b ia s . T h is c o m p u ta tio n is r e p re s e n te d in the fo rm o f a transfer
function.

It d e te rm in e s w e ig h te d to ta l is p a s s ed a s an in p u t to a n a c tiva tio n f u nc tio n to


lO M oAR cPSD |270 42294

p r o d u c e th e o u tp ut. A c tiva tio n fu n c tio n s c h o o s e w h e th e r a n o d e s h o u ld fir e o r n o t.


O n ly th o s e w h o a re fire d m a k e it to th e o u tp u t la y e r. T h e re a re d is tin c tiv e a c tiva tio n
fu n c tio n s a v a ila b le th a t c a n b e a p p lied u p o n th e s o rt o f tas k w e a re p e r fo rm in g .
lO M oAR cPSD |270 42294

Sigmoid Function

● It is a fu n c tio n w h ic h is p lo tte d a s ‘S’ s ha p e d g ra p h .


● Equation : A = 1/ (1 + e -x)
● Nature : N o n - lin e a r. N o tic e th a t X va lu e s lie s b etw e e n - 2 to 2 , Y va lu e s a re ve ry
s te e p . T h is m e a n s , s m a ll c ha n g e s in x w o u ld a ls o b rin g ab o u t la rg e c h a n g e s in
th e v a lu e o f Y .
● Value Range : 0 to 1
● Uses : U s u a lly u s e d in o u tp u t la ye r o f a b in a ry c la s s ific a tio n , w h e re re s u lt is e ith e r
0 o r 1 , a s v a lu e fo r s ig m o id fu n c tio n lie s b e tw e e n 0 a n d 1 o n ly s o , r es u lt c a n b e
p r ed ic te d e a s ily to
be if va lu e is g re a te r tha n 0.5 a n d o th e rw is e .
lO M oAR cPSD |270 42294

Tanh Function

● T h e ac tiv a tio n th a t w o r ks a lm o s t a lw a ys b e tte r th an s ig m o id fu n c tio n is T a n h


fu n c tio n a ls o k n o w n a s Tangent Hyperbolic function. It’ s a c tu a lly
m a th e m a tic a lly s h ifte d v e rs io n o f th e s ig m o id fu n c tio n . B o th a re s im ila r an d c a n
b e d e riv e d fro m e a c h o th e r.

● Equation :-

● Value Range :- - 1 to + 1
● Nature :- n o n - lin e a r
● Uses :- U s u ally u s e d in h id d e n la ye rs o f a n e u ra l n e tw o rk a s it’ s va lu e s lie s
b e tw e e n -1 to1 h e n c e th e m e a n fo r th e h id d e n la ye r c o m e s o u t b e 0 o r ve ry
c lo s e to it, h e n c e h e lp s
in b y b rin g ing m e a n c lo s e to 0 . T h is m a k e s le a rn in g fo r th e n e x t
la ye r m u c h e a s ie r.
lO M oAR cPSD |270 42294

RELU Function

● It S ta n d s fo r . It is th e m o s t w id ely u s e d a c tiv a tio n fu n c tio n .


C h ie fly im p le m e n ted in o f N e u ra l n e tw o rk .
● Equation :- . It g iv e s a n o u tp u t x if x is p o s itiv e a n d 0 o th e rw is e .
● Value Range :- [0 , in f)
● Nature :- n o n - lin ea r , w h ic h m e a n s w e c an e a s ily b a c k p ro p a g a te th e e rro rs a n d
h a ve m u ltip le la y e rs o f n e u ro ns b e in g a c tiv a te d b y th e R e L U fu n c tio n .
● Uses :- R e L u is le s s c o m p u ta tio n a lly e x p e n s ive th a n ta nh a n d s ig m o id b e c a u s e
it in v o lve s s im p le r m a th e m a tic a l o p e ra tio n s . A t a tim e o n ly a fe w n e u ro ns a re
a c tiva te d m a k in g th e n e tw o rk s p ar s e m a k ing it e ffic ie n t a n d e as y fo r
c o m p u ta tio n .
In s im p le w o rd s , R E L U le a rn s th a n s ig m o id a n d T a nh fu n c tio n .

Softmax Function

T h e s o ftm a x fu n c tio n is a ls o a ty p e o f s ig m o id fu n c tio n b ut is h a n d y w h e n w e a re


try in g to h a nd le m u lti- c la s s c la s s ific a tio n p ro b le m s .
lO M oAR cPSD |270 42294

● Nature :- n o n - lin e a r
● Uses :- U s u ally u s e d w h e n try in g to h a n d le m u ltip le c la s s e s . th e s o f tm a x
fu n c tio n w a s c o m m o n ly f o u n d in the o u tp u t lay e r o f im a g e c la s s ific a tio n
p r o b le m s .T h e s o ftm a x fu n c tio n
lO M oAR cPSD |270 42294

w o u ld s q u e e ze th e o u tp u ts fo r e a c h c la s s b e tw e e n 0 a n d 1 a n d w o u ld a ls o d ivid e b y
th e s u m o f th e o u tp u ts .
● Output:- T h e s o ftm a x f u nc tio n is id e a lly us e d in th e o u tp u t la ye r o f th e c la s s ifie r
w h e re w e a re a c tu a lly try in g to a tta in th e p ro b a b ilitie s to d e fin e th e c la s s o f e a c h
in p u t.
● T h e b a s ic ru le o f th u m b is if yo u re a lly d o n ’ t k n o w w h a t a c tiv a tio n fu n c tio n to
u s e , th e n s im p ly u s e a s it is a g e n e ra l a c tiv atio n fu n c tio n in h id d e n la y e rs
a n d is u s e d in m o s tc a s e s the s e d a ys .
● If y o u r o u tp u t is fo r b in a ry c la s s ific a tio n th e n , is ve ry n a tu ra l
c h o ic e fo r o u tp u t la ye r .
● If yo ur o u tp u t is f o r m u lti- c la s s c la s s ific a tio n th e n , S o f tm a x is v er y u s ef u l to
p r ed ic t th e p ro b a b ilitie s o f e a c h c la s s e s .

What are the types of Artificial Neural Networks?

● Feedforward Neural Network: T h e fe e d fo r w a rd n e ur a l n e tw o rk is o n e o f th e m o s t


b a s ic a rtific ia l n e u ra l ne tw o rk s . In th is A N N , th e d a ta o r th e in p u t p ro v id e d tra v e ls
in a s in g le d ire c tio n . It e n te rs in to the A N N th ro ug h th e in p u t la ye r a n d e x its
th ro u g h th e o u tp u t la ye r w h ile h id d e n la ye rs m a y o r m a y no t e x is t. S o th e
fe e d f o rw a rd n e u ra l n e tw o rk h a s a fro n t- p r o p a g a te d w a v e o n ly a n d u s ua lly d o e s
n o t h a ve b a c k p ro p a g a tio n .
● Convolutional Neural Network: A C o n v o lu tio n a l n e u ra l n e tw o rk has som e
s im ila r itie s to th e fe e d - f o rw a rd n eu r al ne tw o rk , w he r e th e c o n n e c tio n s b etw e e n
u n its h a v e w e ig h ts th a t d e te r m in e th e in flu e nc e o f o ne u n it o n a no th e r u n it. B u t a
C N N h a s o ne o r m o r e th a n o n e c o n vo lu tio n a l la y e r th a t u s e s a c o n vo lu tio n
o p e ra tio n o n th e in p u t a n d th e n p a s s e s th e re s u lt o b ta in e d in th e fo rm o f o u tp u t to
th e n e x t la ye r. C N N h a s ap p lic a tio ns in s p e e c h a n d im a g e p r o c e s s in g w h ic h is
p a rtic u la rly u s e fu l in c o m p u te r vis io n .
● Modular Neural Network: A M o d u la r N e u ra l N e tw o rk c o n ta in s a c o lle c tio n o f
d iffe re n t n e u ra l n e tw o rk s th a t w o rk in d e p e n d e n tly to w a rd s o b ta in in g th e o u tp u t
w ith n o in te r ac tio n b etw e e n th e m . E a c h o f th e d iffe re n t n e u ra l ne tw o rk s p e rfo rm s
a d iff e re n t s u b - ta s k b y o b ta in in g u n iq u e in p u ts c o m p a re d to o th er n e tw o rk s . T h e
a d v a n ta g e o f th is m o d u la r n e u ra l n e tw o rk is th a t it b re a k s d o w n a la r g e a n d
c o m p le x c o m p u ta tio na l p ro c e s s in to s m a lle r c o m p o n e nts , thu s d e c re a s in g its
c o m p le x ity w h ile s till o b ta in ing th e re q u ire d o u tp u t.
● Radial basis function Neural Network: R a d ia l b a s is fu n c tio n s a re th o s e fu n c tio n s
th a t c o n s id e r th e d is ta n c e o f a p o in t c o n c e rn in g th e c e n te r. R B F fu n c tio n s h a ve
tw o la ye rs . In th e fir s t lay e r, th e in p u t is m a p p e d in to a ll th e R a d ia l b a s is fu n c tio n s
in th e h id d e n la ye r a n d th e n th e o u tp u t la y e r c o m p ute s th e o u tp u t in th e n e x t s tep .
R a d ia l b a s is fu n c tio n n e ts a re n o rm a lly u s e d to m o d e l the d a ta th a t re p re s e n ts
a n y un d e rlyin g tre n d o r fu n c tio n .
lO M oAR cPSD |270 42294

● Recurrent Neural Network: T h e R e c u rre n t N e u ra l N e tw o rk s a ve s th e o u tp u t o f a


la ye r an d fe e d s th is o u tp u t b a c k to th e in p u t to b e tte r p re d ic t th e o utc o m e o f th e
la ye r. T h e firs t la ye r in th e R N N is q u ite s im ila r to th e fe e d - fo rw a rd n e u ra l ne tw o rk
a n d the re c u rre n t ne u ra l n e tw o r k s ta rts o n c e th e o u tp u t o f th e firs t la ye r is
c o m p u te d . A fte r th is la y e r, e a c h un it w ill r e m e m b e r s o m e in fo rm a tio n fro m th e
p r ev io u s s te p s o th a t it c a n a c t a s a m e m o ry c e ll in p er fo rm in g c o m p u ta tio n s .
lO M oAR cPSD |270 42294

Training Deep Networks

A d e e p n e u ra l n e tw o rk (D N N ) is a n A N N w ith m u ltip le h id d e n la ye r s b e tw e e n th e
in p u t a n d o u tp u t la ye r s

T ra in in g d e e p n eu r al n e tw o r k s is a c ru c ia l s te p in th e f ie ld o f d e e p le a rn in g , e n a b ling
th e s e n e tw o rk s to lea r n fro m d a ta a n d m a k e p re d ic tio n s o r d e c is io n s . B e lo w a re th e
k e y s te p s a n d c o n c e p ts in vo lv e d in tra in in g d e e p n e tw o rk s :
1 . Data Collection and Preparation:
● G ath er a d a ta s e t th a t is re p r e s en tative o f th e p ro b le m yo u w a n t to s o lve . T h is
d a ta s h o uld b e d iv id ed in to tra in in g , va lid a tio n , a n d tes t s e ts .
● P re p ro c e s s th e d a ta b y n o rm a liz in g , s c a lin g , a n d a u g m e n tin g it a s
n e e d e d . D a ta p re p r o c e s s in g h e lp s e n s u re th a t th e n e tw o r k c a n le a rn
e ffe c tive ly .
2 . Model Architecture:
● C h o o s e a n ap p ro p ria te n e u ra l n e tw o rk a rc h ite c tu re fo r yo u r p ro b le m . T h is
m a y in vo lv e s e le c tin g th e ty p e o f la y e rs (e .g ., c o n v o lu tio n a l, r e c u rre n t, fu lly
c o n ne c te d ) a n d ar ra n g in g th e m in a m e a n in g f u l w a y.
● D e te rm in e th e n um b e r o f n e u ro n s o r u n its in e a c h la y e r, th e a c tiva tio n
fu n c tio n s to u s e ,a n d a n y o th e r a rc h ite c tu ra l d eta ils .
3 . Loss Function:
● S e le c t a n a p p r o p r ia te lo s s fu n c tio n ( a ls o k n o w n a s a c o s t o r o b je c tive
fu n c tio n ) th a t q u a n tifie s the d iffe r en c e b e tw e e n th e m o d e l's p r e d ic tio ns a n d
th e a c tu a l tar g e t v a lu e s . T h e c h o ic e o f lo s s fu n c tio n d e p e n d s o n th e p ro b le m
(e . g ., m e a n s q u a re d e rr o r fo r re g re s s io n ,
c ro s s - e n tro p y fo r c la s s ific a tio n ) .
4 . Optimizer:
● C h o o s e a n o p tim iz a tio n a lg o rithm (o p tim iz er ) th a t w ill a d ju s t the m o d e l's
w e ig h ts a n d b ia s es to m in im iz e th e lo s s fu n c tio n . C o m m o n o p tim iz er s
in c lu d e s to c h a s tic g ra d ie n t d e s c e n t ( S G D ) , A d am , R M S p ro p , a n d o th er s .
● S e t h y p e rp a ra m e te rs fo r th e o p tim ize r , s u c h as th e le a rn in g ra te a n d
m o m e n tu m .
5 . Training Loop:
● Ite ra te th ro u g h th e tra in ing d a ta s et in b a tc h e s . F o r ea c h b a tc h :
lO M oAR cPSD |270 42294

● F o rw a r d p a s s : C o m p ute p re d ic tio n s fo r th e in p ut d a ta .
● C o m p u te th e lo s s u s in g th e c h o s e n lo s s fu n c tio n a n d th e tru e la b e ls .
lO M oAR cPSD |270 42294

● B a c k w a rd p as s ( b a c k p ro p a g a tio n ) : C o m p u te g ra d ie nts o f th e lo s s
w ith re s p e c t to th e m o d e l's p a ra m e te rs .
● U p d a te th e m o d e l's p a ra m e te rs u s in g th e o p tim ize r.
6 . Validation:
● P e rio d ic a lly e v a lua te the m o d e l's p e rfo rm a n c e o n a s e p a ra te va lid a tio n
d a ta s e t. T his h e lp s m o n ito r th e m o d e l's p ro g re s s a n d d ete c t o v e rfittin g ( w h en
th e m o d e l p e rfo r m s w e ll o n th e tra in in g d ata b u t n o t o n u ns e e n d ata ).
● A d ju s t h yp e rp a ra m e te rs o r s to p tra in in g if th e v a lid a tio n p e rf o rm a n c e d o e s
n o t im p ro ve o r s ta r ts to d e g ra d e .
7 . Hyperparameter Tuning:
● E x p e rim e n t w ith d if fe re n t h y p e rp a r am ete rs , in c lu d in g le a rn in g ra te s , b atc h
s iz es , n e tw o r k a rc hite c tur e s , a n d re g u la riz a tio n te c h niq u e s (e . g ., d ro p o u t, L 2
re g u la riz a tio n ) to f in d th e
b e s t c o m b in a tio n fo r yo u r p ro b le m .
8 . Regularization:
● A p p ly r e g u la riza tio n te c h n iq u e s to p re ve n t o v e rfittin g . T h e s e te c hn iq u e s
in c lu d e d ro p o u t,
w e ig h t d e c a y ( L 2 re g u la riz atio n ) , a n d e a rly s to p p in g .
9. Data Augmentation:
● A u g m en t th e tra in in g d a ta b y a p p lying ra n d o m tra n s fo rm a tio n s (e .g ., ro ta tio n s ,
flip s ,
c ro p s ) to in c re a s e th e d ive rs ity o f th e tra in in g s am p le s a nd im p ro ve
g e n e ra liz a tio n .
10 . Monitoring and Logging:
● K e ep tra c k o f tra in in g p ro g re s s b y m o n ito rin g m etric s lik e lo s s a n d a c c u ra c y.
● L o g r e le v a n t in fo rm a tio n , s u c h a s tra in in g a n d va lid a tio n p er fo rm a n c e ,
h yp e rp a ra m e te rs ,
a n d m o d e l c h e c k p o in ts , fo r fu tu re re fe re n c e .
11 . Testing :
● A fte r tra in in g , e va lu a te th e fin a l m o d el o n a s e p a ra te te s t d ata s e t th a t it h a s
n e ve r s e e n
b e fo re to as s e s s its g e n e ra liza tio n p e rfo rm a n c e .
12 . Deployment:
● O n c e s a tis fie d w ith th e m o d e l's p e rfo rm a n c e , d e p lo y it fo r m a k in g p re d ic tio n s
o n n ew ,
u n s e en d a ta in a p r o d u c tio n e n v iro nm en t.
lO M oAR cPSD |270 42294

T ra in in g d e e p n e u ra l n e tw o r k s c a n b e c o m p u ta tio n a lly in te n s ive a n d


tim e - c o n s u m in g , re q u irin g a c c e s s to p o w e rfu l h a rd w a re ( e .g . , G P U s o r T P U s ) a n d
c a re fu l e x p er im e n ta tio n to a c h ie v e o p tim a l r es u lts . A d d itio n a lly, te c hn iq u e s lik e
tra n s fe r le a rn in g , w h e re p re - tra in e d m o d e ls a re fine - tun e d fo r s p e c ific ta s k s , c an
b e le ve ra g e d to s p e ed u p tra in in g a n d im p ro ve p e rfo r m a n c e in m a n y c as e s .

Example

F o r a s in g le tra in ing e x a m p le , Backpropagation a lg o rith m c a lc u la te s th e g ra d ie n t o f


th e error function. B a c k p ro p ag a tio n c a n b e w ritte n a s a fu n c tio n o f th e n e u ra l
n etw o rk . B a c k p ro p ag a tio n a lg o rith m s a re a s et o f m e th o d s u s e d to e ffic ie n tly tr ain
a rtific ia l ne u ra l n etw o rk s fo llo w in g a g r a d ie n t d e s c e n t a p p ro a c h w hic h e x p lo its th e
c h a in ru le .

T h e m a in fe a tu re s o f B a c k p r o p a g a tio n a re th e ite ra tive , re c u rs iv e a nd e ffic ie n t


m e th o d th r o u g h w hic h it c a lc u la te s th e u p d a ted w e ig h t to im p ro ve th e n e tw o r k u n til
it is n o t a b le to p e r fo rm th e
lO M oAR cPSD |270 42294

ta s k fo r w h ic h it is b e in g tr ain e d . D e riv ative s o f the a c tiv a tio n fu n c tio n to b e k n o w n a t


n e tw o rk d e s ig n tim e is re q uire d to B a c k p ro p a g a tio n .

N o w , h o w e rro r fu n c tio n is u s e d in B a c k p ro p a g a tio n a n d h o w B a c k p ro p a g a tio n


w o rk s ? L e t s ta r t w ith a n e x a m p le a n d d o it m ath em atic a lly to u n d e rs tan d h o w
e x a c tly u p d a te s th e w e ig ht u s in g B a c k p r o p a g a tio n .

Input values

X 1= 0 .0
5
X 2 = 0 .1
0

Initial weight

W 1 = 0 . 15 w 5 = 0 .4 0
W 2 = 0 .2 0
w 6 = 0 .4 5
W 3 = 0 .2 5
w 7 = 0 .5 0
W 4 = 0 .3 0
w 8 = 0 . 55
lO M oAR cPSD |270 42294

Bias Values

b 1 = 0 .3 5 b 2 = 0 .6 0

Target Values

T1= 0.01
T 2 = 0 .9
9

N o w , w e firs t c alc u la te th e va lu e s o f H 1 a nd H 2 b y a f o rw a rd p a s s .
lO M oAR cPSD |270 42294

Forward Pass
T o find th e v a lue o f H 1 w e f irs t m u ltip ly th e in p u t va lu e fro m th e

w e ig h ts a s H 1 = x 1 × w 1+ x 2 × w 2 + b 1
H 1= 0 .0 5 × 0 .15 + 0 .10 × 0 .2 0 + 0 .3 5

H1=0.3775

T o c a lc u la te th e fin a l re s u lt o f H 1, w e p e rfo rm e d the s ig m o id fu n c tio n as

W e w ill c a lc u la te th e v a lu e o f H 2 in th e s a m e w a y a s H 1

H 2 = x 1× w 3 + x 2 × w 4 + b 1 H 2= 0 . 0 5 × 0 .2 5 + 0 .10 ×
0 .3 0 + 0 .3 5

H2=0.3925

T o c a lc u la te th e f in a l re s u lt o f H 2 , w e p e rfo rm ed th e s ig m o id f u nc tio n a s

N o w , w e c a lc u la te th e v a lu e s o f y1 a n d y2 in th e s a m e w a y a s w e c a lc u la te th e H 1 a n d
H2.

T o fin d th e va lu e o f y 1 , w e firs t m ultip ly th e in p u t v a lu e i.e ., the o u tc o m e o f H 1 a n d H 2


fro m th e w e ig h ts a s
lO M oAR cPSD |270 42294

y1 = H 1× w 5 + H 2 × w 6 + b 2 y1 = 0 .5 9 32 6 9 9 92 ×
0 .4 0 + 0 .5 96 8 8 4 3 7 8 × 0 .4 5+ 0 .60

y1=1.10590597

T o c a lc u la te th e fin al re s u lt o f y1 w e p e rfo rm ed th e s ig m o id fu n c tio n a s


lO M oAR cPSD |270 42294

W e w ill c a lc u la te th e va lu e o f y 2 in th e s am e w a y as y1

y2 = H 1 × w 7 + H 2 × w 8 + b 2 y2 = 0 .5 9 3 26 9 9 9 2 ×
0 .5 0 + 0 .5 9 6 8 8 4 37 8 × 0 .5 5+ 0 .60

y2=1.2249214

T o c a lc u la te th e fin a l re s u lt o f H 1, w e p e rfo rm e d the s ig m o id fu n c tio n as

O u r ta rg e t v a lu es a re 0 .0 1 a n d 0 .9 9 . O u r y 1 a nd y 2 v a lu e is n o t m a tc h e d w ith o u r
ta rg e t va lu e s T 1 a n d T 2 .

N o w , w e w ill fin d the total error, w h ic h is s im p ly th e d iffe r en c e b e tw e e n th e o u tp u ts


fro m th e ta rg et o u tp u ts . T h e to ta l e rro r is c a lc u la te d a s

S o , th e to ta l e rro r is
lO M oAR cPSD |270 42294

N o w , w e w ill b a c k p r o p a g a te th is e rr o r to u p d a te th e w e ig h ts u s ing a b a c k w a rd p a s s .

Backward pass at the output layer

T o u p d a te th e w e ig h t, w e c a lc u la te th e e rro r c o rre s p o n d to e a c h w e ig h t w ith th e


h e lp o f a to ta ler ro r. T h e e rro r o n w e ig h t w is c a lc u la te d b y d iffe re n tia tin g to tal e rro r
w ith re s p e c t to w .

W e p e rfo r m b a c kw a rd p ro c e s s s o firs t c o n s id e r th e la s t w e ig h t w 5 a s

F r o m e q u atio n tw o , it is c le a r th at w e c a n n o t p a rtia lly d iffe re n tia te it w ith re s p e c t to w 5


b e c a u s e th e re is n o a n y w 5. W e s p lit e q u a tio n o n e in to m u ltip le te rm s s o th a t w e c a n
e a s ily d iff er e ntia te itw ith r e s p e c t to w 5 a s

N o w , w e c a lc ula te ea c h te rm o n e b y o n e to d if fe re n tia te E total w ith re s p e c t to w 5 a s


lO M oAR cPSD |270 42294
lO M oAR cPSD |270 42294

P u ttin g th e v a lu e o f e -y in e q u a tio n ( 5 )

S o , w e p u t th e v a lu es o f in e q u a tio n n o (3 ) to fin d th e f in a l re s u lt.

N o w , w e w ill c a lc u la te th e up d a te d w e ig h t w 5 new w ith th e h e lp o f th e fo llo w in g fo rm u la

In the s a m e w a y , w e c a lc u la te w 6 ne w ,w 7 ne w , a n d w 8 n ew a n d th is w ill g ive u s th e


fo llo w ing v a lu es

w5new=0.35
lO M oAR cPSD |270 42294

891648
w6new=4086
66186
lO M oAR cPSD |270 42294

w7new=0.5113012
70
w8new=0.5613701
21

Backward pass at Hidden layer

N o w , w e w ill b a c k p ro p a g a te to o u r hid d en la y e r a n d u p d a te th e w e ig ht w 1 , w 2 , w 3 ,
a n d w 4 a s w e h a ve d o n e w ith w 5 , w 6 , w 7 , a n d w 8 w e ig h ts .

W e w ill c a lc u la te th e e rr o r a t w 1 a s

F r o m e q u atio n ( 2 ) , it is c le a r tha t w e c a n n o t p a rtia lly d iffe re n tia te it w ith re s p e c t to w 1


b e c a u s e th e re is n o a n y w 1. W e s p lit e q u a tio n (1 ) in to m u ltip le te rm s s o th a t w e c a n
e a s ily d iff er e ntia te itw ith r es p e c t to w 1 as

N o w , w e c a lc ula te ea c h te rm o n e b y o n e to d if fe re n tia te E total w ith re s p e c t to w 1 a s

W e a g a in s p lit th is b e c a us e th er e is n o a n y H 1 final te rm in E toatal a s


lO M oAR cPSD |270 42294

w ill a g a in s p lit b e c a u s e in E 1 a n d E 2 th er e is n o H 1 te rm . S p littin g is d o n e a s


lO M oAR cPSD |270 42294

W e a g a in S p lit b o th b e c a u s e th e re is n o a n y y1 a n d y 2 te rm in E 1 a n d E 2 .
W e s p litit a s

N o w , w e fin d th e v a lu e o f b y p u ttin g va lu e s in e q u a tio n ( 18 ) a n d

( 19 ) a s F ro m e q u a tio n ( 18 )

F r o m e q u a tio n (8 )

F r o m e q u a tio n (1 9 )
lO M oAR cPSD |270 42294

P u ttin g th e va lu e o f e -y2 in e q u a tio n ( 2 3 )

F r o m e q u a tio n (2 1 )
lO M oAR cPSD |270 42294

N o w fro m e q u a tio n (1 6 ) a n d (1 7 )

P u t th e va lu e o f in e q ua tio n ( 15 ) a s
lO M oAR cPSD |270 42294

W e h a ve w e ne e d to fig u re o u t as

P u ttin g th e va lu e o f e -H1 in eq u a tio n ( 3 0 )

W e c a lc u la te th e p ar tia l d e riv a tiv e o f th e to ta l n e t in p ut to H 1 w ith r e s p e c t to w 1 th e


s a m e a s w e d id fo r th e o u tp u t n e ur o n :
lO M oAR cPSD |270 42294

S o , w e p u t th e v a lu es o f in e q u a tio n (1 3 ) to f in d the fin a l re s u lt.

N o w , w e w ill c a lc u la te th e u p d a ted w e ig h t w 1 n ew w ith th e h e lp o f th e fo llo w in g fo r m u la

In the s am e w a y , w e c a lc u late w 2 n ew ,w 3 n ew , a n d w 4 a n d th is w ill g iv e u s th e fo llo w in g


va lu e s

w1new=0.1497
80716
w2new=0.199
56143
w3new=0.249
75114
w4new=0.299
lO M oAR cPSD |270 42294

50229

W e h av e u p d a te d all th e w e ig h ts . W e fo u nd th e e rr o r 0 .2 9 8 3 7 1 10 9 o n th e n e tw o rk
w h e n w e fe d fo rw a rd th e 0 . 0 5 a n d 0 .1 in p u ts . In th e f irs t r o u n d o f B a c k p ro p a g a tio n ,
th e to ta l e rro r is d o w n to 0 .2 9 10 2 7 9 2 4 . A fte r r ep e a tin g th is p ro c e s s 1 0 ,0 0 0 , th e to ta l
e rro r is d o w n to 0 . 0 0 0 0 3 5 1 0 8 5 . A t th is p o in t, th e o u tp u ts n e u ro n s g e n e ra te
0 . 15 9 1 2 19 6 0 a nd 0 .9 8 4 0 6 5 7 3 4 i. e ., n e a rb y o u r ta rg e t va lu e w h en w e fe e d fo r w a rd
th e 0 .0 5 a n d 0 .1
lO M oAR cPSD |270 42294

Im p ro vin g D e e p N e tw o rk s

A Deep Learning Model u s u a lly h as v a ria b le p a ra m e te rs th a t m u s t b e s e t b e fo re


tra inin g c a lle d Hyperparameters. T h es e v a lue s a ffe c t th e re s u lts o f th e m o d e l
e ffe c tiv ely . S o th e o p tim a l va lu e s fo r th e s e p a ra m e te rs to o b tain th e b e s t re s u lts
s h o u ld b e f o u n d . F in d in g th e m o s t o p tim a l c o m b in a tio n is c a lle d Hyperparameter
Tuning .

Hyperparameter tuning is th e p ro c e s s o f fin d in g th e o p tim a l va lu e s fo r the


h yp e rp a ra m e te r s o f a ne u ra l n e tw o r k . Hyperparameters a ffe c t th e m o d e l's
p e rf o rm a n c e an d a re s e t b ef o re tr ain in g . H yp e rp a ra m e te r tu n in g c a n im p r o ve a
n e u ra l n e tw o rk 's accuracy and efficiency a n d is e s s e n tia l fo r g e ttin g g o o d re s u lts .

How to Avoid Overfitting while Tuning?

Overfitting is a c o m m o n is s u e w h ile tr a in in g n eu r al ne tw o rk s . It c a n b e p a rtic u la rly


p r o b le m a tic w he n h yp e rp a ra m e te r tu n in g , as it can le a d to s e le c tin g
h yp e rp a ra m e te r s th a t w o rk w e ll o n th e tra in ing d ata b u t n e e d to g e n e ra liz e b e tte r to
u n s e e n d a ta .

H e re a re a fe w m e th o d s th at c a n b e u s ed to a v o id o v e rfittin g d u rin g N e u ra l N e tw o r k

hyperparameter tuning:

● U s e a separate validation set to e v a lu a te th e m o d el's p er fo rm a n c e d u rin g


h y p e rp a ra m e te r tu n in g .
● U s in g regularization techniques, s u c h a s w e ig h t d ec a y (L 2 r eg u lar iza tio n ) o r
d ro p o u t, p r e ve n ts th e m o d e l fro m o ve rf itting to th e tr ain in g d a ta .
● Im p le m e n t early stopping fro m te rm in a tin g th e tra in in g p ro c e s s if th e m o d e l's
p er fo rm a n c e o n th e va lid a tio n s et s ta rts to d e g ra d e .
● D u rin g tra in in g , th e m o d e l's p e rfo rm a n c e is m o nito re d on a s e p a ra te
v a lid a tio n s e t, an d th e tra inin g p r o c e s s is te rm in a te d w h e n th e m o d e l's
p er fo rm a n c e o n th e v a lid a tio n s e t starts to degrade. T h is is b a s e d o n th e
a s s u m p tio n th a t th e m o d e l's p e rfo rm a n c e o n th e v a lid a tio n s e t w ill g e ne r ally
im p ro v e a s th e tra in in g p ro g re s s e s u n til it r ea c h e s a c e r ta in p o in t w h e re th e
m o d e l s ta rts to o v e rfit th e tra in in g d a ta . B y in te rru p tin g th e tra in in g p ro c e s s a t
th is p o in t, early stopping c a n h e lp p re ve n t th e m o d e l fro m o ve rf ittin g th e
tra in in g d a ta .

Functions for Hyperparameter Tuning


lO M oAR cPSD |270 42294

S e v e ra l a p p ro a c h e s c a n b e us e d to p er fo rm h yp er p a ra m e te r tu n in g o n n e u ra l
n e tw o rk s , in c lu d in g

grid search, random search, a n d Bayesian optimization.


lO M oAR cPSD |270 42294

Grid Search

Grid search is a h yp e rp a ra m e te r tu n ing m e th o d in v o lv in g s p e c ifyin g a g rid o f


h yp e rp a ra m e te r va lu e s a n d tra in in g a n d ev a lu a tin g th e n e u ra l n e tw o rk m o d e l fo r
each combination of hyperparameter values. F o r e x am p le , if w e w a n t to tun e th e
le a rn in g ra te a n d th e b a tc h s ize o f a n e u ra l ne tw o rk , w e c an s p e c ify a g rid o f
p o s s ib le va lu e s fo r th e learning rate ( e .g ., 0 .1 , 0 . 0 1 , 0 .0 0 1 ) a n d th e batch size (e . g .,
3 2 , 6 4 , 1 2 8 ) an d tra in a n d e va lu a te th e m o d e l fo r ea c h c o m b in a tio n o f va lu e s . T h e
c o m b in atio n o f h yp er p a ra m e te rs tha t re s u lts in th e b e s t re s u lts o n th e va lid a tio n s e t
is th en s e le c te d a s th e o p tim a l s e t o f h yp e rp a ra m e te r s .

Random Search

R andom s e a rc h is a n o the r h y p e rp a ra m e te r tun in g m e th o d in v o lvin g sampling


lO M oAR cPSD |270 42294

random combinations o f h y p e rp a r am ete r va lu e s a n d tra in in g a n d e va lu a tin g th e


n e u ra l n e tw o rk m o d e l
lO M oAR cPSD |270 42294

fo r e a c h c o m b in a tio n . R an d o m s e a rc h c a n b e more efficient than grid search, a s it


d o e s n o t re q u ire th e e v a lu a tio n o f a ll p o s s ib le c o m b ina tio n s o f h yp e rp a ra m e te rs .

R a n d o m S e a rc h c a n b e b e tte r th a n g rid s e a rc h , e s p e c ia lly if th e m o s t o p tim a l v a lue s


fo r th e m o d e l a re in b e tw ee n th e s p e c if ie d va lu e s . F o r e x a m p le , if th e m o s t
o p tim a l learning rate is
0 . 0 5 an d the s p e c ifie d va lu e s a re 0 .0 1 a n d 0 . 1, th e n th e g rid s ea r c h w ill n o t g ive
g o o d re s u lts ,w h ile th e ra n d o m s e a rc h c a n g e t th e o p tim a l va lu e .

Bayesian Optimization

Bayesian optimization is a m o r e a d va n c e d m e th o d o f h yp e rp a ra m e te r tu n in g tha t


u s e s a probability function b a s e d o n the hyperparameters and accuracy score to
m o d e l th e d is trib u tio n o f the h y p e rp a ra m e te rs an d th e ir im p a c t o n th e m o d e l's
p e rf o rm a n c e.

B a ye s ia n o p tim iz a tio n us e s th e previous values of scores and probabilities to m a k e


a n in f o rm e d d e c is io n in th e fo llo w in g ite ra tio n s . A llo w in g th e m o d e l to fo c u s o n th e
h yp e rp a ra m e te r s th a t c an s ig n if ic a n tly c h a n g e th e re s u lts w hile n o t fo c u s ing o n th e
p a ra m e te rs d o e s n 't a f fe c t th e re s u lt m u c h .

B a ye s ia n o p tim iz a tio n c a n b e more efficient than grid search or random search, as it


c a n a d a p tiv e ly s e le c t th e ne x t s e t o f hy p e rp a ra m e te rs to e v alu a te b a s e d o n th e
p r ev io u s e va lu a tio n s . H o w e ve r, it c a n b e m o re c o m p u ta tio n a lly e x p e n s iv e a n d
re q u ire m o re re s o u rc e s .

O p tim iza tio n A lg o rithm s F o r T ra inin g N e ura l N e tw o rk


lO M oAR cPSD |270 42294

M a n y p e o p le m a y b e u s in g o p tim ize rs w h ile tra in in g th e n e u ra l n e tw o rk w ith o u t


k n o w in g th a t th e m e tho d is k n o w n a s o p tim iza tio n . O p tim ize rs a re a lg o rith m s o r
m e th o d s u s e d to c h a n g e th e a ttr ib u te s o f y o u r n e u ra l n e tw o rk s u c h a s w e ig h ts a n d
le a rn in g ra te in o r d e r to re d u c e th e lo s s e s

m a n y p e o p le m a y b e us in g o p tim ize rs w h ile tra in in g th e n e u ra l n e tw o rk w ith o u t


k n o w in g th a t th e m e th o d is k n o w n a s o p tim iza tio n . O p tim iz e rs a re a lg o rith m s o r
m e th o d s u s e d to c h a n g e th e a ttrib ute s o f yo u r n eu r al n e tw o rk s u c h a s w e ig h ts a n d
le a rn in g ra te in o r d e r to re d u c e th e lo s s e s .
lOM oA RcP SD| 27042 294

Gradient Descent

G ra d ie n t D e s c e nt is th e m o s t b a s ic b u t m o s t u s e d o p tim iz a tio n a lg o rith m . It’ s


u s e d h e a v ily in lin e a r re g re s s io n a n d c la s s ific atio n a lg o rith m s . B a c k p ro p a g a tio n
in n e u ra l n e tw o r k s a ls o u s e s a g ra d ie n t d e s c e n t a lg o rith m .

G ra d ie n t d e s c e n t is a firs t-o rd e r o p tim iza tio n a lg o r ith m w hic h is d e p e n d e n t o n


th e firs t o rd e r d e riv a tiv e o f a lo s s fu n c tio n . It c a lc u la te s th a t w h ic h w ay th e
w e ig h ts s h o u ld b e a lte re d s o th a t th e fu n c tio n c a n re a c h a m in im a . T h ro u g h
b a c k p ro p a g a tio n , th e lo s s is tra n s fe rre d fro m o n e la ye r to a n o th e r a n d th e
m o d e l’ s p a ra m e te rs a ls o k n o w n a s w e ig h ts a re m o d if ie d d e p e nd in g o n th e
lo s s e s s o th a t th e lo s s c a n b e m in im iz e d .

Stochastic Gradient Descent

It’ s a va ria n t o f G ra d ie n t D e s c e n t. It trie s to u p d a te th e m o d e l’ s p a r am ete rs


m o r e fre q u e n tly. In th is , th e m o d e l p a ra m e te rs a re a lte re d af te r c o m p u ta tio n o f
lo s s o n e a c h tra in in g e x a m p le . S o , if the d a tas e t c o n ta in s 1 0 0 0 ro w s S G D w ill
u p d a te th e m o d e l p a ra m e te rs 1 0 0 0 tim e s in o n e c y c le o f d a ta s e t in s te ad o f o n e
tim e a s in G ra d ie n t D e s c en t.

R e g u la riza tio n

R e g u la riz a tio n in d e e p n e u ra l n e tw o rk s is a s e t o f te c h n iq u e s u s e d to p r ev e n t
o v e rfittin g , w h ic h o c c u rs w he n a m o d e l le a rn s to fit th e tra in in g d a ta ve ry c lo s e ly
b u t p e rfo r m s p o o rly o n u n s e e n d a ta . R eg u lar iza tio n m e th o d s a im to e n c o u ra g e
th e m o d e l to g e n e ra liz e b e tte r b y ad d ing c o n s tra in ts o r p e n a ltie s to th e lo s s
fu n c tio n , w h ic h d is c o u ra g e s th e m o d e l fro m le a rn ing c o m p le x p a tte rn s th a t m a y
n o t b e re p re s e n ta tiv e o f th e tru e u n d e rlyin g re la tio n s hip s in th e d a ta .

So m e c o m m o n r e g u la riz atio n te c h n iq ue s u s ed in d e e p n e u ra l n e tw o r k s :

1. L 1 a n d L 2 R e g ula riza tio n :


• L 1 R e g u la riz a tio n (L a s s o ): T h is a d d s a p e n a lty te rm to th e lo s s fu n c tio n th a t is
p r o p o rtio n a l to th e a b s o lu te va lu e s o f th e m o d e l's w e ig h ts . It e n c o u ra g e s th e
m o d e l to le a rn s p a rs e re p re s e n ta tio n s b y p u s h in g m a n y w e ig h ts to e x a c tly z e ro .
• L 2 R e g u la riza tio n (R id g e ) : L 2 re g u la riz atio n a d d s a p e n a lty te rm to th e lo s s
fu n c tio n th a t is p ro p o rtio n a l to th e s q u a re o f th e m o d el's w eig h ts . It d is c o u ra g e s
la rg e w e ig h ts a n d h as th e e ffe c t o f s p re a d in g th e in flu e n c e o f e a c h in p u t a c r o s s
m a n y n eu r o n s , re d u c in g o ve rf ittin g .
2 . D ro p o u t:
• D ro p o u t is a re g u la r iza tio n te c h n iq u e th a t r a nd o m ly d e a c tiva te s (s e ts to ze ro ) a
fra c tio n o f n e u ro n s d u rin g e a c h fo rw ar d an d b a c k w a rd p a s s o f tra in in g . T h is
p r ev e n ts a n y s in g le n e ur o n fro m b e c o m in g o v er ly s p e c ia lize d a n d e n c o u ra g e s
th e n e tw o r k to re ly o n a m o r e ro b u s t s e t o f fe a tu re s .
3 . B a tc h N o rm a liz a tio n :
lOM oA RcP SD| 27042 294

• B a tc h no rm a liz a tio n no rm a liz e s th e in p u ts o f e a c h la ye r in a m in i- b a tc h to h a ve a


m e a n o f z e ro an d a s ta n d a rd d e v ia tio n o f o n e . It h e lp s s ta b ilize tra in in g a n d a c ts
a s a fo rm o f re g u la riza tio n b y re d u c in g in te rn a l c o v ar ia te s h if t. It c a n a ls o re d u c e
th e n e e d fo r o th e r r e g u la riz atio n te c h n iq ue s .

4. E a rly S to p p in g :
• E a rly s to p p in g is a s im p le b u t e ffe c tiv e re g u la riza tio n te c h n iq u e . It
in v o lve s m o n ito rin g th e m o d e l's p e r fo rm a n c e o n a va lid a tio n d a ta s e t d u rin g
tra inin g . If th e p e r fo rm a n c e s ta rts to d e g ra d e ( in d ic a tin g o v e rfittin g ) , tra in in g is
s to p p e d e a rly to p re ve n t th e m o d e l fro m
le a rn in g n o is e in th e d a ta .
5. D a ta A u g m e n ta tio n :
• D a ta au g m e n ta tio n in v o lve s c re a tin g n e w tra in in g e x a m p le s b y
a p p lyin g ra n d o m tra n s fo rm a tio n s (e .g ., ro ta tio ns , flip s , c ro p s ) to th e e x is tin g
tra inin g d a ta . T h is in c re a s e s
th e d ive rs ity o f th e tra in in g s e t a n d h e lp s th e m o d e l g e n er a lize b e tte r.
6. W e ig h t C o n s tra in ts :
• Y o u c a n a p p ly c o ns tra in ts to th e w e ig h ts o f th e n e u ra l n etw o rk to
lim it the ir va lu e s . F o r e x a m p le , yo u c a n u s e th e m a x - n o rm c o n s tra in t, w h ic h
lim its th e m a g nitu d e o f w e ig ht
ve c to r s . T h is c a n h e lp p re v e nt w eig h ts fro m g ro w in g e x c e s s ive ly d u rin g tra in in g .
7. N o is e In je c tio n :
• A d d in g n o is e to th e in p u t d a ta o r to th e a c tiv atio n s o f n e u ro n s
d u rin g tra in in g c a n a c t a s a fo rm o f re g u la riza tio n . N o is e c a n h elp th e m o d e l
b e c o m e m o re ro b u s t to v a ria tio n s in th e
d a ta .
8. D ro p C o n n e c t:
• S im ila r to d r o p o u t, D ro p C o n n ec t ra n d o m ly s e ts a fr ac tio n o f
w e ig h ts to ze ro d u rin g e a ch fo rw a rd and ba c kw a rd pa ss. H o w e ve r, in
D ro p C o n n e c t, w e ig h ts th em s elv e s , n o t n e u ro n s ,
a re d ro p p e d .
9. E n s e m b le M e th o d s :
• C o m b in in g th e p re d ic tio n s o f m u ltip le n e u ra l n etw o rk s ( e n s e m b le
le a rn in g ) c a n le a d to im p ro v ed p e rfo rm a n c e a n d a c t a s a fo rm o f re g ula riza tio n .
T e c h n iq u e s lik e b a g g in g an d
b o o s tin g c a n b e a p p lie d to n e u ra l n e tw o r k s .
10. A d ve rs a ria l T ra in in g :
• T r a in in g th e m od el on a d ve rs a ria l e x a m p le s g e n e ra te d by
p e rtu rb in g th e inp u t d a ta c a n
m a k e th e n e tw o r k m o re ro b us t to s m a ll p e rtu rb a tio ns a n d im p ro ve g en e ra liz a tio n .
lOM oA RcP SD| 27042 294

U N IT -III
Neural Networks: Anatomy of Neural Network, Introduction to Keras: Keras, TensorFlow,
Theano and CNTK, Setting up Deep Learning Workstation, Classifying Movie Reviews:
BinaryClassification, Classifying newswires: Multiclass Classification.

3 .1. A na tom y of a n e u ra l n e tw ork


T r a in in g a n e u ra l n e tw o rk re vo lve s a ro un d th e fo llo w in g o b je c ts :
, w h ich are c om bin e d in to a (or
)T he a n d corre spo ndin g

The , w h ic h d e fin e s th e fe e d b ac k s ig n a l
u s e d f o r le a rn in g T h e , w h ic h d e te rm in e s ho w
le a rn in g p ro c e e d s

Y o u c a n v is u a liz e th e ir in te ra c tio n a s illu s tra te d in fig u re 3 .1 : th e n e tw o rk ,


c o m p o s e d o f la ye rs th a t a re c ha in e d to g e th e r, m a p s th e in p u t d a ta to p re d ic tio n s .
T h e lo s s fu n c tio n th en c o m p a re s th e s e p re d ic tio n s to th e ta rg e ts , p ro d u c in g a lo s s
va lu e : a m e a s u re o f h o w w e ll the n etw o rk ’ s p re d ic tio n s m a tc h w h a t w a s e x p e c te d .
T h e o p tim ize r u s e s th is lo s s va lu e to u p d a te th e n e tw o r k’ s w e ig h ts .

T h e fu n d a m e n ta l d a ta s tru c tu re in n e u ra l n e tw o rk s is th e
A la y e r is a d a ta - p ro c es s in g m o d u le th a t ta k e s a s in p ut o n e o r m o re te n s o r s a n d
th a t o u tp u ts o n e o r m o re te n s o rs . S o m e la y e rs a re s ta tele s s , b u t m o re fre q u e n tly
la ye rs ha v e a s ta te .
D iffe re n t la ye rs a re a p p ro p ria te fo r d iffe re n t te n s o r fo rm ats a n d d iffe re n t ty p e s o f d a ta
p r o c e s s in g .
F o r in s ta nc e , s im p le v e c to r d a ta , s to re d in 2 D te n s o r s o f s ha p e ( s a m p le s , fe a tu re s ) ,
is o fte n p ro c e s s e d b y la ye rs , a ls o c a lled or
lOM oA RcP SD| 27042 294

la y e rs ( th e D e n s e c la s s in K e ra s ). S e q ue n c e d a ta , s to re d in 3 D ten s o rs o f
s h a p e ( s a m p le s , tim e s te p s , fe a tu re s ) , is typ ic a lly p ro c e s s e d b y la y e rs s u c h
a s a n L S T M la y er . Im a g e d a ta , s to r ed in 4 D te ns o rs , is us u a lly p ro c e s s e d b y 2 D
c o n vo lu tio n la y e rs (C o nv 2 D ) .
B u ild ing d e e p - le a rn in g m o d e ls in K e ra s is d o n e b y c lip p in g to g e th e r c o m p a tib le
la ye rs to f o rm u s e fu ld ata - tra n s fo rm a tio n p ip e lin e s .

C o n s id e r th e fo llo w in g e x am p le

W e ’ r e c re a tin g a la y er th a t w ill o nly a c c e p t as in p u t 2 D te n s o rs w h er e th e firs t


d im e n s io n is 7 8 4 ( a x is 0 , th e b a tc h d im e n s io n , is u ns p e c if ie d , a n d th u s a n y va lu e
w o u ld b e a c c e p te d ). T h is la y e r w ill re tu rn a te n s o r w h e re th e firs t d im e n s io n h a s
b e e n tra n s fo rm e d to b e 3 2 .
W h e n u s in g K e ra s , y o u d o n ’ t h a v e to w o rry a b o u t c o m p a tib ility , b e c a us e th e
la ye rs yo u ad d to y o u r m o d els ar e d y n am ic a lly b u ilt to m a tc h th e s h a p e o f th e
in c o m in g la ye r. F o r in s ta n c e, s u p p o s e yo u w r ite th e fo llo w ing
lOM oA RcP SD| 27042 294

T h e s ec o n d la ye r d id n ’ t re c e ive a n inp u t s h a p e a rg u m e n t— in s tea d , it


a u to m atic a lly in fe rre d its in p u ts h a p e a s b e in g the o u tp u t s ha p e o f th e la ye r th at
c a m e b e fo re .

A d e e p - le a rn in g m o d e l is a d ire c te d , a c y c lic g r ap h o f la ye rs . T h e m o s t c o m m o n
in s ta n c e is a lin ea r s ta c k o f la ye rs , m a p p in g a s in g le in p ut to a s in g le o u tp u t.
B u t a s y o u m o ve fo rw a rd , y o u ’ ll b e ex p o s e d to a m u c h b ro a d e r v ar ie ty o f
n e tw o rk to p o lo g ie s . S o m e c o m m o n o n e s in c lu d e th e fo llo w in g :

o Tw o -b ra n ch n e tw o rk s
o M u ltih ea d n etw orks
o In ce ption block s

P ic k in g th e r ig h t n etw o rk a rc h ite c tu re is m o re an a rt tha n a s c ie nc e ; a n d


a lth o u g h th e re a re s o m e b e s t p ra c tic e s a n d p rin c ip le s yo u c a n re ly o n , o n ly
p r ac tic e c a n he lp yo u b e c o m e a p ro p e r n e u ra l- n e tw o rk a rc h ite c t.

O n c e th e n etw o rk a rc h ite c tu re is d e fin e d , y o u s till h a v e to c h o o s e tw o m o re th in g s :


● — Th e qu a n tity th a t w ill be m inim iz ed d uring
tra inin g. Itre pre sen ts a m ea su re of su cce ss for th e ta sk a t h a n d.

● — D e te rm ine s ho w the n etw ork w ill be u pda te d ba sed on th e loss fun ction .

3 .2 . IN TR O DU CTION T O KER A S

D e e p le a rn in g is o n e o f th e m ajo r s u b field o f m a c h in e le a rn in g fra m e w o rk . M a c h in e


le a rn in g is th e s tud y o f d es ig n o f a lg o rithm s , in s p ire d f ro m th e m o d e l o f h u m a n b ra in .
D e e p le a rn in g is b e c o m ing m o re p o p u la r in d a ta s c ie n c e fie ld s lik e ro b o tic s , a rtific ia l
in te llig e nc e (A I), a u d io & v id e o re c o g n itio n a nd im a g e re c o g n itio n . A rtific ia l ne u ra l
n e tw o rk is th e c o r e o f d e e p le a rn in g m eth o d o lo g ie s . D e e p le a rn in g is s u p p o r te d b y
va r io u s lib ra r ie s s u c h a s T h e a n o , T e n s o rF lo w , C a ffe , M x n e t e tc ., K e r as is o n e o f th e
m o s t p o w e rf ul a n d e a s y to u s e p y th o n lib ra ry, w h ic h is b u ilt o n to p o f p o p u la r d e e p
le a rn in g lib ra ries lik e T e n s o rF lo w , T h e a n o , e tc ., fo r c re a tin g d e e p le a rn in g m o d e ls .

O v e rview o f K e ra s

K e ra s ru n s o n to p o f o p e n s o u rc e m a c h ine lib ra rie s lik e T e n s o rF lo w , T h e an o o r


C o g n itiv e T o o lkit ( C N T K ). T h e a n o is a p y th o n lib ra ry u s e d f o r fa s t n u m e ric a l
c o m p u ta tio n ta s k s . T e n s o rF lo w is th e m o s t f am o u s s y m b o lic m ath lib ra r y u s e d fo r
c r e atin g n e u ra l n e tw o rk s a n d d e e p le a rn in g m o d e ls . T e n s o rF lo w is v e ry fle x ib le a n d
th e p rim a ry b en e fit is d is trib u te d c o m p u tin g . C N T K is d e e p le a rn in g fra m e w o r k
d e v e lo p e d b y M ic ro s o ft. It u s e s lib ra rie s s u c h a s P ytho n , C # , C + + o r s ta n d a lo n e
m a c h in e le a rn in g to o lk its . T h e a n o a n d T e n s o rF lo w a re ve r y p o w e rf ul lib ra rie s b u t
lOM oA RcP SD| 27042 294

d iffic u lt to u n d er s ta n d fo r c re a tin g ne u ra l n e tw o r ks .

K e ra s is b a s e d o n m in im a l s tru c tu re th a t p ro v id es a c le a n a n d e a s y w a y to c re a te
d e e p le a rn in g m o d e ls b a s e d o n T e n s o rF lo w o r T he a n o . K e ra s is d es ig n e d to q u ic k ly
d e fin e d e e p le a rn in g m o d e ls . W e ll, K e ra s is a n o p tim a l c h o ic e fo r d e e p le a rn in g
a p p lic a tio n s .

F e a tu r es

K e ra s le v e ra g e s va rio u s o p tim iza tio n te c h n iq ue s to m a k e h ig h le v e l n e u ra l n e tw o rk


A P I e as ie r a n d m o re
p e rf o rm a n t. It s u p p o rts th e fo llo w in g fe a tu re s −

Co nsiste nt, sim ple an d exte nsib le A P I.


M in im a l struc tu re - e a sy to a ch iev e the re sult w itho ut a ny frills.
It su pp orts m u ltiple pla tfo rm s an d ba ck e n ds.
lOM oA RcP SD| 27042 294

It is u se r frie n dly fra m e w ork w h ich ru ns on both CP U a n d G P U .


H igh ly sca la bility of com puta tion .

B e n e fits

K e ra s is h ig h ly p o w er fu l a n d d y n a m ic fra m e w o rk a n d c o m e s u p w ith th e fo llo w in g


a d v a n ta g e s −

La rge r c om m u n ity su pport.


Ea sy to te st.
K era s n e ura l ne tw ork s are w ritte n in P ytho n w h ic h m a k e s thin gs sim pler.
K era s su pports both c on volution a n d re cu rren t ne tw ork s.
D e ep le a rn in g m ode ls a re d isc re te com pon e nts, so th a t, you ca n com bine into m an y
w a ys.

K e ra s :

K e ra s is a h ig h - lev e l n e u ra l n e tw o rk s A P I w ritte n in P y th o n , w h ic h s e rve s a s a n


in te rf a c e fo r b u ild ing a n d tra in in g d e e p le a rn in g m o d els . It's d es ig n e d to be
u s e r- frien d ly, m o d u la r, a n d e x te n s ib le , a llo w in g d e v e lo p e rs to q u ic k ly p ro to typ e a n d
e x p e rim e n t w ith n e u ra l n e tw o rk s . K e ra s p ro v id es a s im p le a n d in tu itive A P I fo r
c o n s tru c tin g va rio u s ty p e s o f n e u ra l n e tw o rk a rc h ite c tu re s , s u c h a s c o n v o lu tio n a l
n e u ra l n e tw o rk s ( C N N s ) , re c u rre n t n e u ra l n e tw o rk s ( R N N s ) , a n d m o re . It s u p p o rts
b o th C P U a n d G P U c o m p u ta tio n s .

T e n s o rF lo w :

T e n s o rF lo w is a n o p e n - s o u rc e m ac h in e le a rn in g fra m e w o rk d e v elo p e d b y G o o g le
B ra in . It p ro v id e s a c o m p re h e n s iv e e c o s y s te m o f to o ls , lib ra rie s , a n d re s o u rc es fo r
b u ild in g a nd d ep lo y in g m a c h in e le a rn in g m o d e ls . T e n s o rF lo w in c lu d e s a lo w - le v el A P I
th a t a llo w s u s e rs to d e f in e a n d e x e c u te c o m p u ta tio n a l g ra p h s , a s w e ll a s a h ig h - lev e l
A P I c a lle d T e n so rF lo w K e ra s , w hic h in te g ra te s s ea m le s s ly w ith K e ra s . In fa c t, s in c e
T e n s o rF lo w 2 .0 , K e ra s h a s b e c o m e th e o ffic ia l h ig h - le ve l A P I fo r b u ild in g m o d e ls in
T e n s o rF lo w .

Thea no :

T h e a n o w a s a n o p e n -s o urc e n u m e ric a l c o m p uta tio n lib ra ry d ev e lo p e d b y th e


M o n tre a l In s titu te fo r L e a rn in g A lg o rithm s ( M IL A ). It a llo w e d u s e rs to d e fin e , o p tim iz e,
a n d e va lu a te m a th e m a tic a l e x p re s s io n s in vo lvin g m u lti- d im en s io n a l a r ra ys e ffic ie n tly.
T h e a n o w a s w id e ly u s e d in th e e a rly d ay s o f d e e p le a rn ing , a n d K e ra s o rig in a lly
s u p p o rte d it as o n e o f its b a c k e n d s . H o w e ve r, T h e an o d e v e lo p m e n t c e a s e d in 2 0 1 7,
a n d it's n o lo n g e r a c tiv e ly m a in ta in e d .

C N T K (M ic ro s o ft C o g nitiv e T o o lk it) :

T h e M ic ro s o ft C o g n itiv e T o o lkit, f o rm e rly k n o w n a s C N T K , is a n o p e n - s o u rc e d e e p


le a rn in g f ra m e w o rk d e ve lo p ed b y M ic ro s o ft. Lik e T e n s o r F lo w a n d T h e a n o , C N T K
p r o vid e s a s c a la b le a n d e f fic ie n t p la tfo rm f o r tra in in g d e e p lea r nin g m o d e ls . K e ra s
a ls o s u p p o rte d C N T K a s o n e o f its b a c k en d s , allo w in g u s e rs to le v e ra g e th e
c a p a b ilitie s o f C N T K w h ile u s in g th e K e ra s A P I. H o w e ve r, a s o f m y la s t u p d a te , C N T K
lOM oA RcP SD| 27042 294

h a s b e e n d e p re c a te d , an d M ic ro s o ft h a s s h ifte d its fo c u s to s u p p o rtin g T en s o rF lo w


a s th e p rim a ry d e e p lea r nin g f ra m e w o rk o n its A z ur e p la tfo rm .

3.3. Setting up Deep Learning Workstation


How to set up your deep learning workstation: the most comprehensive
guidePrerequisites to set up deep learning workstation
P rere qu isite s to se t u p de ep lea rnin g w orksta tion
Th e m ain ste ps to se t u p a de e p le arn in g w ork sta tion
U pd atin g th e Lin u x sy ste m pa ck a ge s
In stallin g th e P y th on -pip com m an d
In stalla tio n ste ps fo r P y th on scie ntific su it in U bu n tu
In stalla tio n of the BLA S library
In stalla tio n of P y th on ba sic libra rie s
In stalla tio n of H D F 5
In stalla tio n of m od ules to v isu a liz e K era s m od el
In stalla tio n of ope n cv pa c ka ge
S e ttin g u p G P U fo r de e p le arn ing
CU D A in sta llation
In stall cu D N N
lOM oA RcP SD| 27042 294

In stalla tio n of T en sorF lo w


In stallin g Ke ra s
O ptio na l insta llation of Th ea n o

I a s s u m e th a t y o u alre a d y h av e U b un tu o n yo u r c o m p ute r. If n o t th e n p le a s e in s ta ll
th e la te s t v e rs io n o f U b u ntu . T h is is th e m o s t fa m o u s o p e n - s o u rc e A lth o u g h it is
p o s s ib le to r u n d e e p lea r nin g K e ra s m o d e ls o n W in d o w s , it is n o t re c o m m e n d e d .
A n o th e r p re r eq u is ite fo r r un n in g d e e p lea r nin g m o d e ls is a g o o d q u a lity G P U . I w ill
a d v is e y o u to h a ve a n N V ID IA G P U in y o u r c o m p u te r fo r s a tis f ac to r y p e rfo rm a n c e . It
is a n e c e s s a ry c o n d itio n n o t m u s t th o u g h . B e c au s e ru n n in g s e q u e n c e p ro c e s s in g
u s in g re c u rre n t n e u ra l n e tw o rk a n d im a g e p ro c e s s in g th ro u g h c o n vo lu tio n a l n e u ra l
m o d e ls in C P U is a d iffic ult p ro p o s itio n .
S u c h m o d e ls m a y ta k e h o u rs to g ive re s u lts w h e n ru n w ith C P U . W h e re a s a m o d e rn
N V ID IA G P U w ill ta k e m e re ly 5 - 10 m in u te s to c o m p le te th e m o d e ls . In c a s e if y o u a re
n o t inte re s te d to in ve s t fo r G P U a n a lte rn a tiv e is u s in g c lo u d s e rv ic e fo r c o m p u tin g
p a y in g h o u rly re n t.
H o w e v e r, in lo n g r u n, th is u s in g this s e rvic e m a y c o s t yo u m o re tha n u p g ra d in g y o u r
lo c a l s y s te m . S o , m y s u g g e s tio n w ill b e if yo u a re s e rio u s a b o u t d e e p le a rn ing a n d
w is h to c o n tin u e w ith ev e n m o d e ra te u s e , g o fo r a g o o d w o rk s ta tio n s e t u p .

T he m a in ste p s to se t up a d e e p le a rn ing w o rk s ta tio n


It is a little tim e - c o n s u m in g p ro c e s s . Y o u w ill r eq u ire a s ta b le in te rn e t c o n n ec tio n to
d o w n lo a d v a rio u s f ile s . D e p e nd in g o n th e inte rn e t s p ee d th e c o m p le te p ro c e s s m a y
ta k e 2 - 3 h o u rs ( w ith a n in te rn e t s p e e d o f 1 g b p s in m y c a s e it to o k 2 ho u rs ) to
c o m p le te . T h e m a in s te p s to s et u p a d e ep le ar n in g w o rk s ta tio n a re a s f o llo w :

U pd atin g th e Lin u x sy ste m pac k ag es


In stalla tio n of P yth on pip co m m a n d. It is th e ve ry ba sic co m m a n d goin g to
be u se d to in sta ll o th e r co m pon e nts
In stallin g th e B a sic Lin e a r A lge bra S u bprogra m (B LA S ) lib ra ry re qu ire d for
m a the m a tica l ope ration .
H D F 5 da ta fra m e in sta lla tion to store h ie ra rch ic a l d ata
In stalla tio n of G ra ph viz to visu a lize Ke ras m ode l
CU D A a nd cu D N N N V ID IA gra ph ics driv ers in sta lla tion
In stalla tio n of T en sorF low a s th e ba ck e n d o f Ke ras
K era s insta llation
In stalla tio n of Th e a no (option al)
S o , w e w ill n o w p r o c e e d w ith th e s te p b y s te p ins ta lla tio n p r o c e s s

U p d a ting the Lin ux s yste m p a c k a g e s


The fo llo w in g lin e o f c o m m an d s w ill c o m p le te th e p ro c e s s o f L in ux s ys te m
u p - g ra d a tio n p ro c e s s . Y o u h a ve to typ e th e c o m m a n d s in U b u n tu te rm in a l. T he
k e yb o a rd s h o rtc u t to o p e n th e te r m in a l is “ C trl+ A lt+ T ” . O p e n th e te rm in a l a n d
e x e c u te the f o llo w in g lin es o f c o d e.

$ s ud o ap t- g e t u p d a te
$ s u d o a p t- g e t - -a s s u m e - y e s u p g ra d e

Ins ta llin g th e P ytho n- p ip c o m m a n d


lOM oA RcP SD| 27042 294

The c o m m a n d is f o r in s ta llin g a n d m a n a g in g P yth o n p a c k a g es . N e x t w h ic h e ve r


p a c k a g e s w e a re g o in g to in s ta ll, th is p ip c o m m a n d w ill b e u s e d . It is a n re p la c e m e n t
o f the e a rlie r c o m m a n d . R u n th e fo llo w in g c o m m a n d to in s ta ll p y th o n - p ip .
$ s u d o a p t- g e t in s ta ll p yth o n - p ip p y th o n - d e v
It s h o u ld in s ta ll p ip in yo u r c o m p u te r. B u t s o m etim e s th e re m a y b e e x c e p tio n s . A s it
h a p p e ne d to m e a ls o .
S e e th e b e lo w s c re e n s h o t o f m y U b u n tu te rm in a l. It s ay s “ U n a b le to lo c a te p a c k a g e
p y th o n - p ip ” .
lOM oA RcP SD| 27042 294

It c re a te d a b ig p ro b le m a s I w a s c lu e le s s a b o u t w h y it is h a p p e n in g . In m y o ld
c o m p u te r , I ha v e u s e d it n o . o f tim e s w itho u t a ny is s u e . A fte r s c o u rin g th e in te rn e t fo r
s e ve ra l h o u rs I g o t th e s o lu tio n . T h is h a s to d o w ith th e P y th o n v e rs io n in s ta lle d in
yo u r c o m p u te r .

If yo u a re a ls o fa c in g th e p ro b le m (m o s t lik e ly if u s in g a n e w c o m p u te r) th e n firs t
c h e c k th e p y th o n v e rs io n w ith th is c o m m a n d .

$ ls /b in /p yth o n*

If it re tu rn s p yth o n ve rs io n 2 ( fo r e x a m p le p yth o n 2 .7 ) th e n u s e p yth o n 2 - p ip c o m m a n d


o r if it re tu r ns h ig h e r v e rs io n p yth o n lik e p y th o n 3 .8 th en u s e p y th o n 3 - p ip c o m m a nd to
in s ta ll p ip . S o , n o w the c o m m a n d w ill b e a s b e lo w
$ s u d o a p t- g e t in s ta ll p yth o n 3 - p ip
U b u n tu b y d e fa u lt u s e s P yth o n 2 w h ile u p d a tin g its p a c k a g e s . In c a s e y o u w a n t to u s e
P y th o n 3 th e n it n e e d s to b e ex p lic itly m e n tio n e d . O n ly P yth o n m e a n s P y th o n 2 f o r
U b u n tu . S o , to c h a n g e th e P ytho n v e rs io n , u s e th e fo llo w in g c o d e .

# In s ta llin g P yth o n 3
$ s u d o a p t- g e t in s ta ll p yth o n 3 - p ip p y th o n 3 - d ev

Ins ta lla tio n s te p s fo r P ytho n sc ie n tific su it in U b un tu


H e re the p ro c e s s d is c u s s e d a re f o r W in d o w s a n d L in u x O p er a tin g s y s te m s . F o r the
M a c u s e rs th ey n e e d to in s ta ll th e P y th o n s c ie n tific s u it via A n a c o n d a . T h e y c an
in s ta ll it fro m th e A n a c o n d a re p o s ito ry. It is c o n tin u o u s ly u p d ate d d o c u m e n t. T he
d o c u m e n ta tio n p ro v id e d in A n a c o n d a is v e ry viv id o n e w ith e ve ry s te p in d e ta il.

Ins ta lla tio n o f th e B LA S lib ra ry


T h e B a s ic L in e r A lg e b ra S u b p ro g ra m ( B L A S ) in s ta lla tio n is th e firs t s te p in s e ttin g u p
yo u r d e e p le a rn in g w o rk s tatio n . B u t o n e th in g M a c u s e rs s h o u ld k e e p in m in d th a t
th is in s ta lla tio n d o e s n o t in c lud e G ra p h v iz a n d H D F 5 a n d th e y h a v e to in s ta ll th e m
s e p a ra tely .

H e re w e w ill in s ta ll O p en B L A S u s in g the fo llo w in g c o m m a n d .

$ su do a pt-ge t in stall bu ild-e sse n tia l cm a k e git


u n zip \ pk g-con fig libo pe nb la s-de v
libla pa ck -de v Installation of Python basic
libraries
In th e n e x t s te p , w e w ill n e e d to in s ta ll th e b a s ic P y th o n lib r ar ie s lik e N u m P y , P an d a ,
P M a tp lo tlib , S c iP y
e tc . T h e s e a re c o re P yth o n lib ra rie s re q u ir ed fo r a n y k in d o f m a th e m a tic a l
o p e ra tio n s . S o , b e it m ac h in e le a rn in g o r d e e p le a rn ing o r an y k in d o f c o m p u ta tio n
in te n s ive ta s k , w e w ill n e e d th e s e lib ra rie s .
S o u s e th e f o llo w in g c o m m a n d in U b u n tu te rm in a l to in s ta ll all th e s e s c ie n tif ic s u ite
s im u lta n e o u s ly .

# in s ta lla tio n o f P y th o n b a s ic lib r a rie s


$ s u d o a p t- g e t ins ta ll p yth o n -p a n d a p yth o n -n u m p y p yth o n - s c ip y p y th o n - m a tp lo tlib
lOM oA RcP SD| 27042 294

p y th o n - y a m l

Ins ta lla tio n o f H D F 5


T h e H ie ra rc h ic a l D a ta F o rm a t ( H D F ) ve rs io n 5 is a n o p e n - s o u rc e file fo r m a t w h ic h
s u p p o rts la rg e , c o m p le x a n d h e te ro g e n e o u s d a ta s o u rc e s . It w a s d e ve lo p e d b y N A S A
to s to re lar g e n u m e ric d a ta file s in e ff ic ie nt b in a ry fo rm a ts . It h a s b e e n c re a te d o n th e
o th er tw o h ier a rc h ic a l d a ta f o rm a ts lik e H D F 4 a n d N e tC D F . H D F 5 d a ta fo rm a t a llo w s
th e d e ve lo p e r to o r g a n iz e h is m a c h in e le a rn in g /d e e p le a rn in g d a ta in a file d ir ec to ry
s tru c tu re ve ry s im ila r to w h a t w e u s e in a n y c o m p u te r. T h is d ire c to ry s tru c tu re c an
b e u s e d to m a in ta in th e h ie ra rc h y o f th e d a ta .

If w e c o n s id e r th e d ire c to r y n o m en c la tu re in th e c o m p u te r filin g s ys tem , th e n th e


“ d ire c to ry” o r “ fo ld e r” is th e “ g ro u p ” a n d th e “ file s ” a re th e “ d a ta s e t” in
c a s e o f H D F 5 d a ta fo rm a t. It h a s im p o rta n c e in d e e p le a rn in g in o rd e r to s a ve a n d
fe tc h th e K e ra s m o d e l fr o m th e d is c .

R u n th e fo llo w in g c o m m a n d to in s ta ll H D F 5 in

yo u r m a c h in e # In s ta ll H D F 5 d a ta f o rm a t to s a v e

th e K e ra s m o d e ls
$ s u d o a p t-g e t in s ta ll lib h d f5 - s e ria l- d e v p y th o n - h 5 p y

Ins ta lla tio n o f m o d ule s to v isu a lize K e ra s m o d e l


lOM oA RcP SD| 27042 294

In th e n e x t s te p w e w ill ins ta ll tw o p a c k a g es c a lle d G ra p h viz a n d p y d o t- n g . T h e s e


tw o p a c k a g e s a re n e c es s a r y to vis u a liz e th e K e ra s m o d e l. T h e c o d e s fo r in s ta llin g
th e s e tw o p a c k a g e s a re as fo llo w :
# In s ta ll g r a p h viz
$ s u d o a p t- g e t in s ta ll
g r ap h viz # In s ta ll
p y d o t- n g
$ s ud o p ip in s ta ll p yd o t- n g
T h e s e tw o p a c k a g e s w ill d e fin ite ly h e lp yo u in th e e x e c u tio n o f th e d e e p le a rn in g
m o d e ls yo u c re a te d . B u t fo r th e tim e b e in g , y o u c a n s k ip th e ir in s ta lla tio n a n d
p r o c e e d w ith th e G P U c o n f ig u ra tio n p a rt. K e ra s c a n a ls o f u nc tio n w ith o u t the s e tw o
pa c ka ges.

Ins ta lla tio n o f o p e n c v p a ck a g e


U s e th e fo llo w ing c o d e to in s ta ll o p e n c v p a c k a g e

# In s ta ll o p e n c v
$ s u d o a p t- g e t in s ta ll p yth o n - o p e nc v

S e tting up G P U fo r d e e p le a rnin g
H e re c o m e s th e m o s t im p o rta n t p a rt. A s y o u k n o w th a t G P U p la ys a n im p o rta n t r o le
in d e e p le a rn in g m o d e llin g . In th is s e c tio n , w e a re g o in g to s e t u p th e G P U s u p p o r t
b y ins ta llin g tw o c o m p o n en ts n a m e ly C U D A a n d c u D N N . B u t to fu n c tio n p r o p e rly
th e y ne e d N V ID IA G P U .

A lth o u g h y o u c a n ru n yo u r K e ra s m o d e l e ve n in th e C P U , it w ill ta k e m u c h lo n g e r tim e


to tra in a m o d e l to c o m p a r e to th e tim e ta k e n b y G P U . S o , m y a d vic e w ill b e if y o u a re
s e rio u s a b o u t d e e p le a rn in g m o d e llin g , th e n p la n to p ro c u re a n N V ID IA G P U ( u s in g
c lo u d s e rv ic e p a yin g h o u rly re n t is a ls o an a lter n ative ) .

L e ts c o n c e n tra te o n th e s e ttin g u p o f G P U a s s u m ing th at y o u r c o m p ute r a lre a d y h a ve


la te s t o n e .

C U D A ins ta lla tio n


To in s ta ll CUD A vis it N IV ID IA d o w n lo a d pag e fo llo w in g th is lin k
h ttp s :/ /d e v elo p e r.n v id ia .c o m /c u d a - d o w n lo a d s . Y o u w ill la n d in th e fo llo w in g p a g e .
It w ill a s k f o r s e le c tin g th e O S y o u a re u s ing . A s w e a re u s in g U b u n tu h e re (to k no w
w h y to u s e U b u n tu a s th e p re fe rre d O S re a d th is a rtic le ) s o c lic k U b u n tu.
lOM oA RcP SD| 27042 294

C U D A in s ta lla tio n - O S s e le c tio n


T h e n it w ill a s k o th e r s p e c ific a tio n s o f yo ur w o rk s ta tio n e n v iro n m e n t. S e le c t th e m a s
p e r yo u r e x is tin g s p e c if ic a tio n s . L ik e h e re I h a v e s ele c te d O S a s L in u x . I a m u s in g a
D e ll L a titu d e 34 0 0 la p to p w h ic h is a 6 4 b it c o m p u ter , s o in n e x t o p tio n I s e le c te d
x 8 6 _ 6 4 ; th e L in u x d is tr ib u tio n is U b un tu ve rs io n 2 0 .0 4 .

F in a lly the in s talle r ty p e yo u h a v e to s e le c t. H e re I h a v e s e le c te d th e ne tw o rk in s ta lle r


m a in ly b e c a u s e it h a s c o m p a ra tive ly s m alle r d o w n lo a d s ize . I a m u s ing m y m o b ile
in te rn e t fo r th e tim e b e in g . S o , it w a s the b e s t o p tio n f o r m e . B u t yo u c a n c h o o s e a n y
o f th e o th e r lo c al in s ta lla tio n o p tio n s if th e re is n o c o n s tra in o f in te rn e t b a nd w id th . T h e
p lu s p o in t o f lo c a l in s ta lla tio n is y o u h a ve to d o th is o n ly o n c e .
lOM oA RcP SD| 27042 294

C U D A in s ta lla tio n - s p e c ific a tio n s e le c tio n


A s a ll th e s p e c if ic a tio n s ar e m e n tio n e d , N V ID IA w ill p ro vid e y o u th e in s ta lle r. C o p y
th e c o d e fro m th e re a n d ru n in U b un tu te rm in a l. It w ill u s e U b u n tu ’ s a p t to in s ta ll th e
p a c k a g e s , w h ic h is th e m o s t e a s ie s t w a y to in s ta ll C U D A .

C U D A in s talla tio n c o d e
$ w get
h ttp s ://d e v e lo p e r. d o w n lo a d .n vid ia .c o m /c o m p u te /c u d a/ re p o s / ub u n tu 2 0 0 4 /x 8
6 _ 6 4 /c u d a- u b u n tu 2 0 0 4 .p in
$ s u d o m v c u d a - u b un tu 20 0 4 .p in /e tc /a p t/p re fe re n c e s .d /c u d a - re p o s ito ry- p in - 6 0 0
$ s u d o a p t- k e y a d v - - fe tc h - k e y s
h ttp s ://d e ve lo p er. d o w n lo ad .n vid ia. c o m /c o m p u te /c u d a /re p o s /ub un tu 2 0 0 4 /x 8 6 _ 6 4 /7 f
a 2 af 8 0 .p ub
$ s u d o a d d - a p t- re p o s ito ry " d e b
h ttp s :/ /d e v elo p e r.d o w n lo a d .n v id ia .c o m /c o m p u te /c u d a /re p o s /u b un tu 20 0 4 /x 8 6 _ 64 /
/"
$ s ud o ap t- g e t u p d a te
$ s ud o a p t- g e t - y ins ta ll c u d a

Ins ta ll cu D N N
lOM oA RcP SD| 27042 294

T o d o w n lo a d th e s p e c if ic c u D N N file fo r yo u r o p er a tin g s ys te m a n d lin u x d is trib u tio n


yo u h a v e to v is it th e N IV ID IA d o w nlo a d p a g e .
lOM oA RcP SD| 27042 294

D o w n lo a d in g c u D N N

T o d o w n lo a d th e lib ra ry, y o u h a ve to c re a te a n a c c o u n t w ith N V ID IA . It is a


c o m p u ls o r y s te p .

N V ID IA m e m b e r s hip f o r D o w n lo a d in g

c u D N N F ill in th e n e c e s s a ry fie ld s .

N V ID IA m e m b e rs h ip fo r D o w n lo a d in g c u D N N

A s y o u fin is h re g is tra tio n a w in d o w w ith s o m e o p tio n a l s e ttin g s w ill a p p e a r. Y o u c a n


s k ip th em a nd p r o c e e d fo r th e n e x t s te p .
lOM oA RcP SD| 27042 294

N V ID IA m e m b e rs h ip fo r D o w n lo a d in g c u D N N

A s h o rt s u rve y b y N IV ID IA is th e n e x t s te p . A lth o u g h it is o n th e e x p e rie n c e a s


d e v e lo p e r, yo u c a n f ill it w ith a n y o f th e o p tio n s ju s t to na v ig ate to th e d o w n lo a d p a g e .

D o w n lo a d s u rve y fo r c u D N N

N o w th e p ag e w ith s e ve ra l d o w n lo a d o p tio n s w ill a p p e a r an d yo u h a v e to c h o o s e


a c c o rd in g to yo u r s p e c ific a tio n s . I h a v e s e le c te d th e fo llo w in g d e b ia n file fo r m y
w o rk s ta tio n .

S e le c tin g th e O S fo r c u D N N d o w n lo a d

D o w n lo a d th e file ( th e file s ize is a ro u n d 3 0 0 m b in m y c a s e ). N o w to in s ta ll th e


lib r a ry, firs t c h a n g e th e d ire c to ry to e n te r in th e d o w n lo a d fo ld e r a n d e x e c u te th e
in s ta ll c o m m a n d .
lOM oA RcP SD| 27042 294

O n c e yo u a re in th e d ire c to ry w h e re th e lib ra ry h a s b e e n d o w n lo a d e d ( b y d e fa u lt it is
th e d o w n lo a d fo ld er o f y o u r c o m p u te r) ru n th e c o m m a n d b e lo w . U s e th e file n a m e in
p la c e o f * * * * in th e c o m m a n d .

$ s ud o d p k g - i d p k g - i * * * * * * .d e b
Y o u c a n fo llo w th e in s ta lla tio n p r o c e s s fr o m th is p a g e . W ith th is th e c u D N N in s ta lla tio n
is c o m p le te d .

Ins ta lla tio n o f T e n so rF lo w


T h e ne x t s te p is in s ta lla tio n o f T en s o rF lo w . It is ve ry s im p le . J u s t e x e c u te th e b e lo w
c o m m a n d to ins ta llT e ns o rF lo w w itho u t G P U s u p p o rt u s in g th e p ip c o m m a n d .
lOM oA RcP SD| 27042 294

# In s ta llin g T e n s o rF lo w u s in g p ip 3 c o m m a n d fo r P yth o n 3
$ s ud o p ip 3 ins ta ll te n s o rflo w

Ins ta llin g K e ra s
T h is is th e fin a l s te p o f s ettin g u p y o u r d e e p le a rn in g w o rk s ta tio n a n d yo u a re g o o d to
g o . Y o u c a n ru n th e s im p le b e lo w c o m m a n d .

$ s ud o p ip 3 ins ta ll k e ra s
O r yo u c an in s ta ll it fro m G ithu b to o . T h e b e n e fits o f in s ta llin g K e r as fro m G ith u b a re
th a t y o u w ill g e t lo ts o f e x a m p le c o d e s fro m th e re . Y o u c a n ru n tho s e e x a m p le s c rip ts
to te s t th em o n y o u r m a c h in e . T h e s e a re v e ry g o o d s o u rc e o f le a rn in g .
$ g it c lo ne h ttp s ://g ith u b .c o m /f c h o lle t/k e ra s
$ c d k e ra s
$ s u d o p yth o n s e tu p . p y in s ta ll

O p tio na l ins ta lla tio n o f T he a n o


In s ta lla tio n o f T h e a n o is o p tio n a l a s w e h a ve a lre a d y in s ta lled T e n s o rF lo w . H o w e ve r,
in s ta llin g T h e a n o c a n p ro v e a d va n tag e o u s w h ile b u ild in g K e ra s c o d e an d s w itc h in g
b e tw e e n T e ns o rF lo w an d T h e a n o . E x e c u te th e c o d e b e lo w to fin is h in s ta llin g T h e a n o :

$ s ud o p ip 3 in s ta ll th e an o
C o n g ra tu latio n s !!! y o u ha v e fin is h e d w ith a ll in s ta lla tio n s a n d c o m p le te d th e s e t u p f o r
yo u r d e e p le a rn in g w o r k s ta tio n. Y o u a r e n o w re a d y to e x e c u te y o u r firs t c o d e o f d e e p
le a rn in g ne u ra l n e tw o r k .

I h o p e th is a rtic le w ill p ro v e h e lp fu l to s e t up y o u r d e e p le a rn in g w o rk s ta tio n . It is


in d e ed a le n g th y a rtic le b u t c o ve rs a ll te c hn ic a litie s w h ic h y o u m a y n e ed in c a s e o f
a n y d iffic u lty d u rin g th e p r o c e s s . A little k n o w le d g e a b o u t e ve ry c o m p o n e n t y o u a re
in s ta llin g a ls o h e lp s y o u to m a k e a n y fu rth e r c h a n g e s in th e s e ttin g .

L e t m e k n o w ho w y o u fin d th is a rtic le b y c o m m e n tin g b e lo w . P le a s e m e n tio n if a n y


in fo rm a tio n I m is s e d o r a n y d o u b t yo u h a v e re g a r d in g th e p ro c e s s . I w ill try m y b e s t
to p ro vid e th e in fo rm a tio n .
lOM oA RcP SD| 27042 294

3.4. Classifyin g M ov ie Re v ie w s: B ina ry Cla ssific ation

T w o -c la s s c la s s if ic a tio n , o r b in a ry c la s s ific a tio n , m a y b e th e m o s t w id e ly a p p lie d kin d o f


m a c h in e- le a rn in g p ro b le m .
In th is e x a m p le , yo u ’ ll le a rn to c la s s ify m o vie re v ie w s a s p o s itiv e o r n e g a tiv e , b a s e d o n th e te x t
c o n te n t o f th e re v ie w s .

Y o u ’ ll w o rk w ith th e IM D B d a ta s e t: a s e t o f 5 0 ,0 0 0 h ig h ly p o la rize d re v ie w s fro m th e In te rn e t


M o v ie D ata b a s e . T he y ’ r e s p lit in to 2 5 ,0 0 0 re v ie w s fo r tra in in g a n d 2 5 ,0 0 0 re v ie w s fo r te s tin g ,
e a c h s e t c o n s is tin g o f 5 0 % n e g a tiv e a n d 5 0 % p o s itive re view s .

T h e a rg u m e n t n u m _ w o rd s = 1 0 0 0 0 m e a ns yo u ’ ll o n ly k ee p th e to p 1 0 ,0 0 0 m o s t fr e q u e n tly
o c c u rr in g w o rd s in th e tra inin g d a ta . R a re w o rd s w ill b e d is c a rd e d . T h is a llo w s y o u to w o rk w ith
ve c to r d a ta o f m a n a g ea b le s ize

T h e v a ria b le s tra in _ d a ta a n d te s t_ d a ta a re lis ts o f r e vie w s ; e a c h re v ie w is a lis t o f w o rd in d ic e s


( e nc o d in g a s e q u e n c e o f

B ec a us e yo u ’ re re s tric tin g yo u rs e lf to the to p 1 0 ,0 0 0 m o s t fre q u e n t w o rd s , n o w o rd in d e x w ill


e x c e e d 1 0 ,0 0 0 :

> > > m a x( [m ax ( s e q u en c e) fo r s eq u en c e in tra in _ d a ta ]) o u tp u t:

9999

F o r k ic k s , h ere ’ s h o w y o u c a n q u ic k ly d e c o d e o n e o f th e s e re v ie w s b ac k to E n g lis h w o rd s :
lOM oA RcP SD| 27042 294
lOM oA RcP SD| 27042 294

Y o u c a n ’ t fe e d lis ts o f in te g e rs in to a n e u ra l n e tw o r k . Y o u h a v e to tu rn yo u r lis ts in to te n s o r s .
T h e re a re tw o w a ys to d o th a t:

P a d y our lists so tha t th e y a ll h a ve th e sa m e le n gth , tu rn the m in to a n in teg er te n sor of sh a pe


(sa m ples, w ord_in dices), a n d th en u se a s th e first la y er in you r ne tw ork a lay er ca pa ble o f h a n dlin g
su ch in te ger te n sors (the Em bed ding la ye r, w h ic h w e’ ll cov er in de ta il la te r in th e book ).

O ne -h ot e n code y ou r lists to turn the m into v e ctors of 0 s a n d 1s. Th is w o uld m ea n , for in sta n ce ,
turn in g the se que n ce [3 , 5 ] in to a 10 ,0 0 0 -dim e n sion al ve ctor tha t w o uld be a ll 0 s exc ep t fo r ind ic es 3
a n d 5 , w h ich w o uld be 1s. T he n you cou ld u se as the first la ye r in y our n e tw ork a D e nse la ye r, ca pa ble of
h a ndling floa tin g-p oint v ec to r d ata .

L e t’ s g o w ith th e la tte r s o lu tio n to ve c to riz e th e d ata , w h ic h yo u ’ ll d o m a n u ally fo r m a x im um


c la rity

H e re ’ s w h a t th e s a m p le s lo o k lik e n o w :

> > > x _ tr a in [0 ]

Y o u s ho u ld a ls o v e c to rize y o u r la b e ls , w h ic h is s tr aig h tfo rw a rd :

T h e in p ut d a ta is v ec to rs , a n d th e la b e ls are s c ala rs ( 1s a n d 0 s ): th is is th e e a s ie s t s e tu p yo u ’ ll
e ve r e n c o u nte r. A ty p e o f ne tw o rk th a t p e rf o rm s w e ll o n s u c h a p r o b le m is a s im p le s ta c k o f
fu lly c o n n e c te d ( D e n s e ) lay e rs w ith re lu a c tiv a tio n s :D e n s e (1 6 , a c tiv a tio n = 're lu ').
lOM oA RcP SD| 27042 294
lOM oA RcP SD| 27042 294

F in ally , yo u n ee d to c h o o s e a lo s s fu n c tio n a nd a n o p tim ize r. B e c a u s e y o u ’ re f a c in g a b in a ry


c la s s if ic a tio n p ro b le m a n d th e o u tp u t o f yo u r n e tw o r k is a p ro b a b ility ( yo u e n d y o u r n e tw o rk
w ith a s in g le - u n it la y e r w ith a s ig m o id a c tiv a tio n ), it’ s b e s t to u s e th e b in a ry_ c ro s s e n tro p y
lo s s . It is n ’ t th e o n ly v ia b le c h o ic e : yo u c o u ld u s e , fo r in s ta n c e , m e a n _ s q u ar e d _ e rr o r. B u t
c r o s s e n tro p y is u s u a lly th e b e s t c ho ic e w h en yo u ’ re d e a lin g w ith m o d e ls th a t o utp u t
p ro b a b ilitie s .

In o rd e r to m o n ito r d u rin g tra in in g th e a c c u ra c y o f th e m o d e l o n d a ta it h a s n e ve r s e e n b e fo re ,


yo u ’ ll c re a te a v a lid a tio n s e t b y s e ttin g a p a rt 1 0 ,0 0 0 s a m p les fro m the o r ig ina l tra in in g d a ta

Y o u’ ll n o w tra in th e m o d e l fo r 2 0 e p o c h s ( 2 0 ite ra tio n s o ve r a ll s a m p le s in the x _ tra in a n d


lOM oA RcP SD| 27042 294

y_ tra in te n s o r s ), in m in i- b a tc he s o f 5 1 2 s a m p le s . A t th e s a m e tim e , y o u ’ ll m o n ito r lo s s a n d


a c c u ra c y o n th e 1 0 ,0 0 0 s a m p le s th a tyo u s e t a p a rt. Y o u d o s o b y p a s s in g the va lid atio n d a ta a s
th e v a lid a tio n _ d a ta ar g u m e n t.
lOM oA RcP SD| 27042 294

let’ s us e M atp lo tlib to p lo t th e tr a in in g a nd v alid a tio n lo s s s id e b y s id e ( s e e fig u r e 3 .7 ) , a s


w e ll a s th e tra in in g a n d v alid a tio n a c c u ra c y ( s e e fig u re 3 .8 ) .

w h a t y o u w o u ld e x p e c t w h e n r un n in g g ra d ie n t d e s c e n t o p tim iz a tio n—
th e q u an tity yo u ’ re try in g to m in im iz e s h o u ld b e le s s w ith e v e ry ite r atio n .
lOM oA RcP SD| 27042 294
lOM oA RcP SD| 27042 294

3.5 .

In th is e x a m p le , w e w ill b u ild a m o d e l to c la s s if y R eu ter s ne w s w ire s in to 4 6 m u tu a lly e x c lu s ive


to p ic s . B e c a u s e w e h a v e m a n y c la s s e s , th is p ro b lem is a n in s tan c e o f m u ltic la s s c la s s ific atio n ;
a n d b e c a u s e e a c h d a ta p o in t s h o u ld b e c la s s ifie d in to o n ly o n e c a teg o ry , th e p ro b lem is m o re
s p e c ific a lly a n ins ta nc e o f s in g le - la b e l, m u ltic la s s c la s s ific a tio n . If e a c h d a ta p o in t c o u ld b e lo n g
to m u ltip le c a te g o rie s (in th is c a s e , to p ic s ), y o u ’ d be fa c in g a m u ltila b e l, m u ltic la s s
c la s s if ic a tio n p ro b le m .

w id e ly u s e d to y d a tas e t fo r te x t c las s ific a tio n . T h e re ar e 4 6


d iff ere n t to p ic s ; s o m e to p ic s a re m o re rep re se n te d tha n o th e rs ,
p a rt o f
K e ra s .

2.

3.
lOM oA RcP SD| 27042 294
lOM oA RcP SD| 27042 294

D a ta P re p

ve c to r ize th e in p ut d a ta

= n p .ze ro s ( (le n (s e q u e n c e s ), d im en s io n ))

fo r i, s e q u e n c e in

e nu m e r ate (s e q ue n c e s ): re s u lts [i,

se qu e n ce ] = 1.

v ec to rize _ s e q u e n c e s ( te s t_ d a ta ) # 2

V e rc torize tra in ing d ata

V en cotriz e testin g da ta

ve c to r ize th e la b e l w ith th e e x ac t s a m e c o d e a s in th e p re vio u s

e x a m p le . d e f to _ o n e _ h o t( la b e ls , d im e n s io n = 4 6 ) :

la b e l in

e n u m e ra te ( la b e ls ) :

re s u lts [i, la b e l] = 1 .

re tu rn r e s ults

o n e _ h o t_ tra in _ la b e ls =

o n e _ h o t_ te s t_ la b els = to _ o n e_ h o t( te s t_ la b e ls )# 2

V e rctorize tra in ing la be ls

V en cotriz e testing labe ls

N o te th a t th e re is a b u ilt- in w a y to d o th is in K e ra s :

fro m te n s o rflo w .k e ra s .u tils im p o rt to _ c a te g o ric a l

o n e _ h o t_ tra in _ la b e ls =

o n e _ h o t_ te s t_ la b els =

to _ c a te g o ric a l( te s t_ la b e ls )
lOM oA RcP SD| 27042 294

B uildin g th e m od el

T h is to p ic - c la s s if ic a tio n p ro b le m lo o k s s im ilar to th e p re v io u s m o v ie - re v ie w c la s s ific atio n : in


b o th c a s e s , w e a re try in g
d im e n s io n ality o f th e o u tp u t s p a c e is m u c h
la rg e r.

In a s ta c k o f D e ns e la y e rs lik e th a t w e h a ve b e e n u s in g , e a c h la y er c a n o n ly a c c e s s in fo rm a tio n
p r es e n t in th e o u tp u t o f th e p re vio u s la ye r. If o ne lay e r d ro p s s o m e in f o rm a tio n re lev a n t to th e
c la s s if ic a tio n p ro b le m , th is in fo r m a tio n c a n n e ve r b e re c o ve re d b y la te r la ye rs : e a c h la ye r c a n
p o te n tia lly be co m e an in fo rm a tio n b o ttle n e c k . In th e p re v io u s ex a m p le , we used
1 6- d im en s io na l in te rm e d ia te la ye rs , b ut a 1 6 - d im e n s io n a l s p a c e m a y b e to o lim ite d to le a rn to
s e p a ra te 46 d iffe re n t c la s s e s : su ch s m a ll la y er s m ay ac t a s in fo rm a tio n b o ttle n e c ks ,
p e rm an e n tly d r o p p in g re lev a n t in fo rm a tio n . F o r th is re a s o n w e w ill u s e la rg e r la ye r s . L e t’ s g o
w ith 6 4 u nits .

M o d e l D e fin a tio n
m od el =
k e ra s .S e q ue n tia l([
lay e rs .D e n s e ( 6 4 ,
a c tiva tio n = 'r elu ') ,
lay e rs .D e n s e ( 6 4 ,
a c tiva tio n = 'r elu ') ,
lay e rs .D e n s e ( 4 6 ,
a c tiva tio n = 's o ftm a x ')
])

N o te a b o ut th is a r c h ite c tu re :

W e e n d th e m od el w ith a De n se la ye r of size 46 . Th is m e an s for e a ch inp ut sa m ple, th e n e tw ork


w illou tpu t a 46 -dim e n sio na l v ec tor. Ea ch en try in th is ve ctor (e ac h dim e n sio n) w ill e n code a
diffe re n t ou tpu t cla ss.

Th e last la ye r u ses a softm a x ac tiv ation . Y ou sa w th is pa tte rn in th e M N IS T e xa m ple. It m e a ns th e


m od el w ill ou tpu t a pro ba bility distribu tion ove r th e 4 6 diffe re n t o utpu t c la sses — for e ve ry inp ut
sa m ple, the m ode l w ill produ ce a 46 -dim e n siona l ou tp ut v ec to r, w h e re o utpu t[i] is th e pro ba bility
tha tth e sa m ple be lon gs to c la ss i. Th e 46 sc ore s w ill sum to 1.

Th e b est loss fu n ction to u se in th is ca se is c ate gorica l_c rosse n tropy . It m ea su re s th e d ista n ce


be tw ee n tw o proba bility distribu tion s: h ere , betw e e n the pro ba bility distribu tion ou tpu t b y th e
m od el a nd th e tru e distribu tion of the la bels. B y m inim izin g th e dista n ce be tw ee n the se tw o
distribu tio ns, y ou tra in th e m ode l to o utpu t som e th in g a s close a s po ssib le to the tru e la be ls.

Co m pile th e

m o de l

m o de l.com p ile (o ptim iz e r= 'rm spro


lOM oA RcP SD| 27042 294

p',

m e tric s = ['a c c u ra c y '])

V a lid a tio n o f th e a p p ro a c h

x _ tra in [:10 0 0 ]

p a rtia l_ x _ tra in = x _ tra in [1 0 0 0 :]

y_ va l =

o n e _ h o t_ tra in _ la b e ls [:10 0 0 ]

p a rtia l_ y_ tra in = o ne _ ho t_ tra in _ la b e ls [1 0 0 0 :] let’ s

tra in th e m o d e l fo r 2 0 e p o c hs .

T r ain in g th e m o d e l

h is to ry = m o d e l. fit( p a rtia l_ x _ tra in ,

p a rtia l_ y_ tra in ,

e po ch s= 2

0 , b a tc h _ s iz e = 5 12 ,

v a lid a tio n _ d a ta = (x _ va l,

y _ v a l) )
lOM oA RcP SD| 27042 294

E p o c h 1/ 20

- 2 s 8 1m s /s te p - lo s s : 3 .1 0 2 9 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = a c c u ra c y :
= == = ]

E p o c h 2 /2 0

- 1s 3 8 m s /s te p - lo s s : 1. 4 8 0 7 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = a c c u ra c y :
= == = ]
0 .6 9 9 2 - v a l_ lo s s: 1. 29 6 4 - va l_ a c c u ra c y:
0 .7 2 3 0

E p o c h 3 /2 0

- 1s 3 6 m s /s te p - lo s s : 1. 0 7 6 3 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = a c c u ra c y :
= == = ]

E p o c h 4 /2 0

- 1s 3 6 m s /s te p - lo s s : 0 .8 4 4 1 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = a c c u ra c y :
= == = ]

E p o c h 5 /2 0

- 1s 3 7 m s/ ste - loss: -
p a c cu ra cy :
0 .8 6 5 8 - v a l_loss: 0 .9 456 - v a l_a cc u ra cy : 0 .8 0 5 0

E poch 6 /2 0

16/ 16 [= = == == = == = == = == == = == = == = == = == =] - 37 m s/ st - lo ss: 0 .5 2 3 7 a ccu ra c y:


1s ep -
0 .8 94 5 - va l_loss: 0 .92 0 3 - va l_a ccu rac y:
0 .8 0 40

Epoc h 7/ 2 0

16/ 16 [= = == = == == = == = == = == == = == = == = == = ] - 3 6 m s/ st - loss: 0 .4 18 1 ac cu ra cy :
1s ep -
0 .9 160 - va l_lo ss: 0 .8 7 65 - va l_ acc urac y:
0 .8 140 Ep och

8 /2 0

- 1s - loss: -
35 m s/ ste p 0 .3 48 5 a c cu ra cy :
lOM oA RcP SD| 27042 294

0 .9 3 16 - v a l_ lo s s : 0 .8 8 9 5 - va l_ ac c u ra c y: 0 . 8 0 6 0

E p o c h 9 /2 0

- 1 s 3 6 m s /s te p - lo s s : 0 .2 8 2 9 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = a c c u ra c y :
= == = ]
0 .9 3 9 0 - va l_ lo s s : 0 . 8 8 2 9 - va l_ a c c u ra c y :
0 .8 1 10

E p o c h 1 0 /2 0

- 1 s 3 6 m s /s te p - lo s s : 0 .2 2 4 6 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = a c c u ra c y :
= == = ]

- 1 s 3 6 m s /s te p - lo s s : 0 .18 9 4 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = a c c u ra c y:
= == = ]
0 .9 5 3 2 - va l_ lo s s : 0 .9 0 6 0 - va l_ a c c u ra c y:
0 .8 12 0

E p o c h 1 2 /2 0

1 6 /16 [= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ] - 1 s 3 7 m s / s te p - lo s s : 0 . 17 6 5 - a c c u ra c y:
0 . 9 53 8 - v a l_ lo s s : 0 .9 0 6 8 - v a l_ a c c u ra c y :

0 . 8 1 6 0 E p o c h 1 3 /2 0

1 6 /16 [= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ] - 1s 3 7 m s / s te p - lo s s : 0 . 16 1 0 - a c c ur a c y:

0 .9 5 2 9 - v a l_ lo s s : 0 .9 3 9 4 - va l_ a c c u ra c y : 0 .8 10 0
lOM oA RcP SD| 27042 294

E p o c h 1 4 /2 0

- 1 s 3 7 m s /s te p - lo s s : 0 . 14 3 8 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = a c c ur a c y:
= == = ]
0 .9 5 7 4 - va l_ lo s s : 0 .9 2 5 4 - v al_ a c c ur a c y:
0 .8 19 0

E p o c h 1 5 /2 0

- 1 s 3 5 m s /s te p - lo s s : 0 .1 3 0 5 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = a c c ur a c y:
= == = ]
0 .9 5 8 4 - v a l_ lo s s : 0 .9 6 6 6 - va l_ a c c u ra c y:
0 .8 0 6 0

E p o c h 1 6 /2 0

- 1 s 3 7 m s /s te p - lo s s : 0 .1 2 9 1 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = a c c u ra c y:
= == = ]
0 .9 5 6 2 - v a l_ lo s s : 0 .9 5 3 7 - v a l_ a c c ur a c y:
0 .8 12 0

E p o c h 1 7 /2 0

- 1s 3 6 m s /s te p - lo s s : 0 .11 4 0 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = ac c u ra c y:
= == = ]
0 .9 5 9 3 - va l_ lo s s : 1 .0 2 0 2 - va l_ a c c u ra c y:
0 .8 0 2 0

E p o c h 1 8 /2 0

- 1 s 3 8 m s /s te p - lo s s : 0 .1 16 7 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = a c c ur a c y:
= == = ]
0 .9 5 6 7 - v a l_ lo s s : 0 .9 9 4 2 - v a l_ a c c u ra c y :
0 .8 0 7 0

E p o c h 1 9 /2 0

- 1s 3 8 m s /s te p - lo s s : 0 .0 97 2 -
[= = = = = = = = = = = = = = = = = = = = = = = = = = a c c u ra c y :
= == = ]
0 .9 6 6 9 - va l_ lo s s : 1 .0 7 0 9 - va l_ a c c u ra c y:
0 .7 9 6 0

E p o c h 2 0 /2 0

1 6 /16 [= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ] - 1s 3 4 m s /s te p - lo s s : 0 .1 0 3 5 - a c c u ra c y:
lOM oA RcP SD| 27042 294

0 .9 6 0 7 - va l_ lo s s : 1 .0 5 3 0 - v a l_ a c c u ra c y : 0 .8 0 2 0

P lo tting th e train in g a n d va lida tion

lo ssloss = h istory.h istory['loss']

ra n g e ( 1 , le n ( lo s s ) + 1 )

p lt. p lo t( e p o c h s , lo s s , 'b o ',

la b e l= 'T r a in in g

lo s s ') p lt.p lo t(e p o c h s ,

va l_ lo s s , 'r',

la b e l= 'V a lid a tio n

lo s s ') p lt.title ( 'T ra in ing a n d

va lid a tio n lo s s ') p lt.x la b e l( 'E p o c h s ')

p lt. yla b e l( 'L o s s ')

p lt. le g e n d ( ) p lt.s h o w ( )
lOM oA RcP SD| 27042 294

You might also like