Download as pdf
Download as pdf
You are on page 1of 2
© Awontepces @ Home (a Nadel catalog nae sing 1 Notebooks & tomated ot Desget "Prompt iow mee B oan A ss EE components petnes 2B. emironmens © Moats LUNAR CAPTALSON BHO. > Machine. Lanning Rozsn > Notebooks Dicetingstneatarsi> | 0 rimtodeepFonmch x »ooes os 1 Eatin VSCode “| @ compute Benoa oe oh youre onthe notebok perenne ae ata! ant x Deep Learning Explained Module 2 - Lab - Introduction to Keras 1.0 Getting started with Keras ‘Wis notebook wl provide fret ook at sing the Karas pactage to define rin and evaite dep tring mal with Ker y the end afte leon ou willbe abe o worth bare esfonar arentertre mi ner eral nets Fedonard endo ae ane of carob moses Caled sequential modes which rent define wth Ker ure, same bac regulon introduced, toa egulzaton methods ane coveain asutseuent son The dete ofeetorrd modes and egurzton wil be redid in ote ston. Forno os on Becoming confor tn sing Ker sa youare prepared forth est the abs is eau Note: his oto0ok as constructed and ested sing Anaconda 3 with Python 37. Risse that the anda Aracond sacks en 1.1 Keras architecture east wrapper over oer deep ling tarenors Kee provides conten and snpfed AP fr wg thes undying meek. thi Iezon we wil fc onthe wie ued Bython AP Present Ke suport enor, CNT an Theano Fre ab for ths coure, we wil ewig Kara a wrapper ontop of escron 1.2 Overview of Keras documentation ‘One ofthe many nce fare of Keri comlete and ref docmenation Complete docenertation incség italian rtucton can be found cn the eas website As you ka owe wah Kees, you wl wan tel toe wetsndeted doarenation abd examples on ths se The bok Cees esing with ton by Fano Chl, the eter Karas provides depth example and dco ona wide range of Sep leaming sppcatons, 2.0 A first feed-forward Keras example ‘thot thar ay tty an sample We il bul snp fear nev ntwork oc handurtn i rom the fous MNT data et NIST contain 6000 bled arin mages an 100 tes mages Many people comer te MNT caret he elo wer 2.1 Loading the MNIST data set MnsTis bitin too the Kerassdataset package We ony edt import the sakage ae then a The fn step to mport the packages we wl nes for th rest of itebook Erect the code in the cl below ole hee pockages. Tit ee shold eat thout eres orang eveything sae cet 2 Mole smote ker equirenent already setisfiet: Karas Sn /oneconda/sne/Supyter.env/1Sb/pytons.6/aste hate: you ay need to restart the kernel to use updueed packages shapes (205-2) 2 Mole Snstelt tesortion egutrenent siresay satis packeger (fram tentortlon) egutrenent atresay satis tensorfion) (2:3:9) serserfien) (2.36.8) (from teaortaeu) (158.3) 45 Janeconda/ ane Super_anv/2Eb/pynond.8/eSte-pachagee (Fron Serworfioy) (8.25.3) egulrenant slreedy tlsFled: tectrboardc2 4402.13 An /anaconda/anes/Soyter_env/LS0/pythand6/4Se-packagee (fron tanorflee) (23-8) z ‘erento $n anaconda ter at/a/reor. a tecpctaee (2.13.8) isppe.a in /raana/ une amsinpyiena-seracags (ren ] ‘yping-censions 6.80.68 in /macana/ eStart. afte so ereclone 1.8 fn anaconaov/ yer ar/ breton. aveste rece (tom ‘sbepet12.9 Sy fanaconda/enve/Sunytarenv/A8b/pytnens.A/ebtecpackanes (fron 124.3 £5 /anaconda/ ante Supyter_env/ 120 pytnons8/sStepachapee 2 ingore tereswutls te Ka cetera raed fron Keres pert reguarizere © pore nunpy 88 22 smtplotLissrlsne 30 o5:3:45.018452: eanzortiou/core/slettor/e 2525-06-39 03:35:45 057587: W tengcflau/conpar/cfatancone/tile/py_et8e.e2:38] TFTRT aurntngs aula not fine feature guad.ce:282] This TencorFlow binary fe Nate ta the Tesrflow bcknd has ban loaded along wth varios Keres packages Kea making clo Tener to pao Now, oe the vag snd testing mages and conesponding abl by executing the coded in the all below. The Toad dats method cts ‘tpl ofthe mages nce for tring ana tsb dels ith the dt lade e'zhave ape at come ofthe content The ages ofthe haute eae epteente a reangularanaysof dlrersion 2228 You an seth by executing the cade ne cel belo A print train inegestel-shaey 2s, 28) The handritan images ae al rsa, so do at have aco dimension The codein the cel blow ily ofthe 6000 image of handritn cigs ong wth hess, seat code and caine he eis, “OG 2 for in rants, 20, 4): 2 paeltnonon(eein’Snages ly enapeette.blnary) cn) 4 Frbnt(otabe = * + serene aabe2etD) as 2s 2.2 Prepare the data for training. Asis ash main mig poles epg ais an nara sep. Mot ca ala ppanion ce bs nos The NIST ages ae stored at 3-4 tensor. Each nage tensor as dimension DOD 2828 Honever, ota # nur etna images we mutate hi representation ota ach image ea vector ct ngth 8 28 Th rest be 32-4 enor of Serensons saa00 (28 +28), Forher ml crete wth Kaas, and mest ther des eating famevers operate on ating point mame: The iy scale pie vale ofthe images te coded a tagerin the age (0,258) These pie ver st be toned to eating pt an ten adarons tein age {00,10}, kr ithe ae for waning many machine arang modeler bes tute andar aks for traning dowp rl mst. The codein the cl below fatten the nages and conven tepals toa standardize eating point number recut ths code 2 prlns(train_tnages shapes tele tapes shpe) 2 rain images train anager. reshape (e200, 28°28) asypa('#loat2")/255 rineCerain Annes share) (sone, 25, 28) (se00,) (see, 783) feet? Nose te orginal spe an reuing shape of the trinng mage tensor nation the ays now of ype Flo? [ste the code nthe cel sont apply the eae tanfomaton othe tet images 4 print(vert_inges.shape, test aaneissap 2 fest_inapes = test_anapes reshape (i000, 5 pnt cert_tages snap). 028) -atype( #002") /255 asec, 25, 28) c2800,) ‘see, 728) since we at working an a clan problem, he tel values must be of ateporal ype Ect he code nthe cel blow and examine he cosing of thee abs 2 prineterasn Basson The be are coded ar integers carespondng othe sgtin he mage These ves mus Be cond categral ye, For ea, 5B pitiyaseer( toss") 9 Faecedee boss v8. Eee) xe ple dagena() 12 plot tose(history) Loss vs. Epoch os traning oss as, A et ptot_sceursy(nintery) 2“ Sebslece s naseory history val tors!) 3 tevtlace » MetorysMetord val Tere] Se TEtcangeta, ten(eest ace) + 0) 5 Pataplot(x, estate, color = “hed, Label = “tent sccuraey") pltploccr sr a's “Stalning secures) pPitcaeoes (Epoch pit ylaet(aceuray') 5 patcedene( Aeureey vee pen") 2 pltagens(ioce"lover sare") polite terres cree) Accuracy vs. Epoch aoe — test accurcy tring accuracy 7 7 @ @ 7% 4.0 Adding hidden layers Next weil ad an ado den aye t the model. Aon aes a apy tthe mode to represent complex uncon. Hower the tensors passed betwoen ayers beyond the input 2 es models Sequential) 3 fmtsadi(leyere;Deae(Sl2, activation = 'relu'y inputshape = (28°28, 9) 4 sad layers,Danae(SI2, setivetion © reli’) 5 meseda(ioyers\Oenao(38, activation * '2Fenen')) oe sumaryt) 4 compile the waded 5 meceomileloptiniser + ‘oeprop', Zens ‘exteporscal cossertrany Fy wvtriee « [accuracy 3 maaan 2 tpvrendoneewa(s5e4) 35 Nveery « anes tiece sean Jaber, v “(eestinages, test_iabeis)) ‘ayer Cre) ouRpet Shape aren @ denset (Dees) (ore, 532) sasene dence s (Dese) (ore, 532) ase ence 6 (Danse) (sore, 19) soe Tote params: 669765 (2.55 18) Trainabe parame: 663705 (2.55 18) on-treinabie paren: © (0 2 plot asse(nsetony) Loss vs. Epoch — test ors traning loss o10 7s 50 75 wo us wo Ws 200 a Tee ‘Accuracy vs. Epoch 100 0070. training accuracy och ovens, nen compare othe sine aye example the evr ting more obvious. This sha 5.0 Adding regularization to the model ingot 1 and epareation methods. The tee of repulratin wl be adcesed in ther sve In ation ou can ad documentation on the eas regutartzers pcage 1 ening mode incuding nur enn. The Kr regia er package pr analy of 901 othe model wea 266 argument ith the vale of reglars30rs.12(0,01) Thisadde weight decay bse te coe Expect exciton to tke ale 2 fe = motele sequertial() 5 patada(ioveresDerue(SI2, setetion © “relay Sopot 2 area segasertzerarpularssets2(0-09:))) 5 mnteda(zevers,ensn(si2, tctivetton = "relu'y kernel rgularizereregularisers120,082))) = (28028, 9, oe ae avons sensaa, aessuation #"sofenst")) somone 2 Detine an optincar ebSect end compile the waded ae Gpeiniser = mapron() Bi pntcconse(optiniser © ptinizer, Loss = ‘eategoriel_crossentrany', metrics = ('aecuraey"D) 22 an Fit the copited model 15 poveendon seaaC7es4) BS Notony « mes tuc(enain 59/48 ( 69148 2s M/sten = Lone 0.8197 = acurney: 0.9018 - val Lote 0.3447 ses | Be Jas/stap = Lose 0.2126 ~ acuraey: 0.988 - vale 0.1585 59/48 1 De Tmrstap = Lone 0.8181 = acursey: 0.9817 val_Lone 0.3355 69/469 25 ena/atep —20n8) @n88 - accuracy 0.9880 — yel.tosss 9.8230 2 plot aessenistony Loss vs. Epoch an Accuracy vs. Epoch a ons A "waning accuracy 7s 50 75 wo us wo WS 200

You might also like