Keras, Tensorflow va Torch kutubxonalari.
Mavzu: Keras, Tensorflow va Torch kutubxonalari. Reja: 1. Keras, Tensorflow va Torch kutubxonalari xaqida 2. K e r a sd a c h iz i q li r e gr e ss iy a m od eli n i qurish 3. Python keras va tensorf low kutubx ona l aridan foyda l anish. K eras – b u P y t hon-da y oz i lgan, T hea n o y oki Tensor f low-ning a sos i ga quril g an O chiq K odli net ro n t a r m o q kut u b x o n a s i dir. U m odull i , te z k o r v a ish l at ish uc hu n q ulay holatda G o o g l e k o m pa n i y a s i m uhandisi F ran s ua C hol e t is h l a b c hi q q a n. K eras – b u hisob- ki toblar n i a m a lg a os hi r ish u c hun Tensor Fl ow, CNTK y ok i Thea n o “ Backend” k ut u bxonalar i d a n f o y d al a n a dig a n , y u qo r i dara j ada i s hla y d i gan A PI(a p p lic a ti o n p rogra mm in g interfa c e) di r. K eras ni m a? K era s ni n g i sh l a b c hiq ilishiga a s osiy sab a b shuki – u n ga c ha bos h qa ne y r o n t ar m oqla r i ku t ub x o n a la r i d a n f o y dal a ni s h n o qula y roq bo ` lgan y a ’ n i sint a ksisi qi y in ro q b o ` l g a n. K e r as y uqo r i - d ara j a li A P I m od ella r n i y aratish, qa t la m l ar n i
belgila s h y oki b i r n e c h t a k iri s h- c hiqi s h m o d e l la r i n i bo s h qar is h i m konini ber a di. K eras m od e l n i y o`q ot ish (Loss f unction) v a opti m i zatsi y a ( O pti m izat i on function) f u n k si y a s i bil a n ko m pil y atsi y a qil a d i , va m odelni o `q it i sh ni f i t f u nksi y asi o r qa l i a m al g a oshiradi. K era s d a ne y r o n t ar m o q qurish K eras ne y ron t a r m o q m ode l ini j u da tez t a y y or l ash i m k o nini b e r ad i . B i r ne c h a q ato r l i oddiy tar m o q m ode l ini y arati s h u ch un , K er a s bu b o rada y ordam b e r i shi m u m kin . Q u y id a g i m i s o lga qar an g: K era s d a ne y r o n t ar m o q qurish ( I n pu t ) m odel = Sequ e nti a l() m odel.add(Dense ( 512, i np u t _ s hap e =(7 8 4 , ))) m od el.a d d (Ac ti v a ti o n('re l u')) m odel.add(Dro p o ut (0.2))
K era s d a ne y r o n t ar m o q qurish ( H idd e n) m odel = Sequ e nti a l() m odel. ad d(Dense ( 51 2 , i npu t_ shape=(784 , ))) m odel.add(Act i va t i on('relu')) m odel. ad d(Dropout ( 0. 2 )) m odel.add(Dense ( 51 2 )) m odel.add(Activation('re l u')) m odel. ad d(Dropout ( 0. 2 )) K era s d a ne y r o n t ar m o q qurish ( O ut p ut ) m odel = Sequ e nti a l() m odel.add(Dense ( 512, i np u t _ s hap e =(7 8 4 , ))) m odel.add(Activation('re l u')) m odel.add(Dro p o ut (0.2))
m odel.add(Dense ( 51 2 )) m od el. ad d( Ac t iva tio n ( 'r e l u ' )) m odel.add(Dro p o ut (0.2)) m odel. ad d(Dense ( 10 )) m odel.add(Act i va t i on('sof t m ax')) K era s ni n g a s o s i y t u s h un c h a la r i K era s d a g i a so s iy s truk tura bu m od e l. M od ellar b ir qa n cha q a t l a m lar d an t as h k i l t o p i s h i m u m kin . K er a s d a qat l a m larning bir ne c hta t uri m av j u d . ◦ Ket m a- k et tar ti bl i ( S e quent ia l ) m odel ◦ K o n v ol y u t s ion qa t l a m ◦ M a xP o oli n g q a t l am ◦ Zi c h ( De n s e ) qatl a m ◦ Dr o p o u t q a t l am
Ket m a-ket t a r t i b l i ( S e que n tial) m od e l Ket m a-ket t a r t ibli m ode ln i n g a so s iy g' o y asi shun c h a ki Ker a s q a t la m l ar i ni k e t m a - k et t a r t ib da jo y lash t i r is h dir. Ya ` n i q a tla m lar tu r g a n t ar ti bi b o ` y i c ha is h g a tush i r ila d i Kon v o l y utsion q a tl a m Kon v o l y utsion q a tl a m – b u m as s ivlar u st i da b ir ne c h t a f i l t r l a r d an f o y dal a n g a n h o l da ula r d a n tu r li xil xu s u s i y a t la r n i a j r a tib olish uc hu n qo`ll an ilad i g a n qa t la m di r Kon v o l y utsion q a tl a m ReLU-ni f a o ll as h ti r i s h fu n k t si y as i d a n f o y dal a n a dig a n va kirish shak l i(i n put s h a pe) 3 2 0 x 3 2 0 x3 b o ' lgan 4 8 t a 3x3 o'lcha m dagi f i lt r i bo`lg a n konvo l yutsi o n q at la m . i nput_sh a pe= ( 32 0 , 3 2 0, 3 ) #this is the i np u t sh a p e of an i m a ge 320 x 320 x 3 m odel.add( C o nv2D(48, (3, 3 ), ac t i va ti o n = ' r e l u', i np u t _ s h a pe= i n put_ s hape)) Kon v o l y utsion q a tl a m ning b oshqacha k o `rinishi: m odel. ad d(Conv2 D ( 4 8 , ( 3 , 3 ), a c t ivati o n = 're l u')) Ma x Po oling qatlam