Momwe mungakhalire Keras ndi TensorFlow kuchokera backend ku Ubuntu

momwe mungakhalire ma kera pa ubuntu

Mukamaliza Makina Ophunzirira Makina, Ndimayang'ana komwe ndipitilize. Madera otukuka omwe amagwiritsidwa ntchito pamaphunziro otsogola a Octave / Matlab siomwe anthu amagwiritsa ntchito, chifukwa chake muyenera kulumpha china chake chapamwamba kwambiri. Mwa omwe akufuna kuti andilimbikitse kwambiri ndi Keras, pogwiritsa ntchito backend TensorFlow. Sindikufuna kudziwa ngati Keras ali bwino kuposa zida zina kapena chimango kapena kusankha TensorFlow kapena Theano. Ndikungolongosola momwe zingakhalire mu Ubuntu.

Choyamba ndimayesa kuyiyika kuchokera pazolemba zamasamba ovomerezeka, ndipo zinali zosatheka, ndimakhala ndi vuto nthawi zonse, funso losayankhidwa. Pamapeto pake ndinapita kuyang'ana maphunziro apadera amomwe mungakhazikitsire makamera mu Ubuntu Ndipo komabe ndakhala masiku awiri ndikumakhala nthawi yochuluka usiku. Pamapeto pake ndakwanitsa ndipo ndikusiyirani momwe ndazichitira kuti mwina zingakupangireni njira.

Pomwe tikutsatira njira zomwe masamba awebusayiti omwe ndakusiyirani kuchokera kumagwero kumapeto kwa phunziroli, tiika PIP yomwe ndinalibe, kuyang'anira maphukusiwo. pip mu linux ndikuti, dongosolo loyang'anira phukusi lolembedwa mu python.

sudo apt-kukhazikitsa python3-pip sudo apt kukhazikitsa python-pip

Tumizani ku mndandanda wathu wamakalata

Ikani zabwino pogwiritsa ntchito pip3

Ndi Virtualenv titha kupanga mapangidwe ndi Python. Titha kunena kuti malo okhala ndi kuphatikiza ntchito komwe titha kugwira ntchito ndi maphukusi osiyanasiyana komanso mitundu yosiyanasiyana.

Apa mavuto oyamba adawonekera pogwiritsa ntchito sudo ndi maphunziro omwe ndimatsatira (sudo pip3 kukhazikitsa virtualenv) adabwezeretsa cholakwika chotsatira

Mavuto kukhazikitsa virtualenv

Ena akufuna kuchotsa chikwatu cha http pachinsinsi koma sizinagwire ntchito. Yankho lina lomwe sindinanenepo ndikugwiritsa ntchito -H, ndiye kuti, sudo -H pip3 kukhazikitsa virtualenv. Koma yankho losavuta kwambiri lomwe lagwira ntchito kwa ine lakhala

pip3 kukhazikitsa zabwino

pip3 m'malo mwa pip zikutanthauza kuti tigwiritsa ntchito python 3

Ndipo tikuti tiike Virtualenvwrapper

Virtualenvwrapper wa vitamini, amasintha ntchito ndi machitidwe ambiri a Virtualenv. Zimatithandiza kupanga chilichonse kukhala chosavuta. Ndicho chifukwa chake timagwiritsa ntchito.

Kutsatira njira zophunzitsidwa ndi maphunziro osiyanasiyana, zimawoneka kuti chilichonse chidayikidwa koma ndikamayendetsa mkvirtualenva, yomwe ndi imodzi mwamasitepe pansipa, nthawi zonse imandiuza kuti sazindikira malangizo awa. Pamapeto pake ndinatha kuyiyika ndikupanga virtuanenvwrapper kugwira ntchito ngati iyi.

pip kukhazikitsa zabwino

Momwe mungayikitsire viralealenvwrapper

Tikawona Sinthani .bashrc ndi ndipo tiika gwero lathu, ndiye kuti, adilesi yomwe tili ndi fayilo ya virtualenvwrapper.sh

kutumiza NTCHITO_HOME = $ HOME / .virtualenvs kutumizira kunja PROJECT_HOME = $ HOME / Devel source /home/nmorato/.local/bin/virtualenvwrapper.sh

Zinthu zazing'onozi ndizomwe ndimadziwa kuti anthu amayamba kuzitsamwitsa chifukwa sadziwa momwe angasinthire mzerewu ndikupeza njira yopita kufayilo yawo. Chifukwa chake pali mafotokozedwe ang'onoang'ono pazithunzi za 4

Momwe mungapezere ndikuwona gwero kapena njira ya fayilo

  1. Tsegulani Nautilus, woyang'anira fayilo ya Ubuntu ndikudina m'malo ena. Ikuwonetsani hard drive yanu, sankhani yomwe Ubuntu yaikidwapo.
  2. Pano tili pamzu wa dongosolo lathu. Dinani pa lupita pamwambapa ndipo makina osakira adzawonetsedwa.
  3. Lowetsani dzina la fayilo, pamenepa alirezatalischi.sh ndipo ikupezani omwe ali m'dongosolo lonse
  4. Mukwere pamwamba, dinani batani lamanja ndikupatsa katundu. Pamenepo mudzawona njira yake yonse. Yemwe muyenera kutenga kuti musinthe fayilo ya .bashrc

 

Chabwino ndizo. Kamodzi .bashrc ikasinthidwa, tsatirani mzerewo mu kontrakitala, mwa ine

gwero /home/nmorato/.local/bin/virtualenvwrapper.sh

thamangani zabwino pa ubuntu

Pambuyo pa vuto poyang'ana phunzirolo

Zolakwitsa: virtualenvwrapper sanapeze virtualenv panjira yanu

mu gawo ili ndinayenera kukhazikitsa pip ndi

sudo apt kukhazikitsa zabwino

Njira ina ndi

sudo apt kukhazikitsa - kukhazikitsa zabwino

 

 

Timapanga chilengedwe cha keras mu virtualenv ndi virtualenvwrapper

M'malo mwanga ndazitcha keras_tf kuchokera ku TensorFlow yomwe ndi backend yomwe tidzagwiritse ntchito ndi Keras ndipo ndimapanga chitukuko.

mkvirtualenv keras_tf-tsa

Ndiosavuta kwambiri. Ndicho chayikidwa kale. Kuyambira pano nthawi iliyonse yomwe tikufuna kulowa tidzalowa

ntchito keras_tf

Ikani Kuyenda kwa Tensor

Malangizo osavuta kwambiri. Chowonadi ndichakuti pano ndazisunga mosavuta. Ngati mungayang'ane zolembedwa zovomerezeka, pali njira zambiri.

pipi kukhazikitsa - kukweza tensorflow

Kuwona kuti zonse zikuyenda bwino timachita mogwirizana

 python >>> tengani tensorflow >>>
Ndili ndi cholakwika chokhudzana ndi ma CPU akale omwe ndikakambe kumapeto

Ikani makamera

Kuti muyike Keras, muyenera choyamba kukhazikitsa kudalira kwa python. Ndikothekanso kupezerapo mwayi ndikuyika OpenCV tsopano, koma popeza sindigwiritsa ntchito pakadali pano sindinafune kuyipitsitsanso.

pip install numpy scipy pip install scikit-phunzirani pipi kukhazikitsa pilo pipi kukhazikitsa h5py

Ndipo pamapeto pazomwe tafotokozazi mutha kukhazikitsa Keras :)

pip kukhazikitsa makamera

Timayang'ana fayilo ya keras.json kuchokera ~/.makamera/makamera.json mutha kudina Search mu nautilus, woyang'anira mafayilo a Ubuntu

Makhalidwe oyenera ayenera kukhala ofanana ndi awa

{"floatx": "float32", "epsilon": 1e-07, "backend": "tensorflow", "image_data_format": "channels_last"}

Koposa zonse onani kuti ndi kumbuyo kotani tensorflow ndipo osati theano ndi chithunzi_data_format chomwe chimayika njira_last ndipo ayi njira_first by theano

Ngati simukupeza keras.json

Nthawi zambiri fayilo ya keras.json ndi ma subdirectories ake sangapangidwe mpaka mutatsegula kontena ndikulowetsa phukusi mwachindunji.
Chifukwa chake ngati ndi choncho ndipo simungathe kuzipeza m'dongosolo lanu, tsatirani njira zotsatirazi.
workon keras_tf python yoitanitsa kera kusiya ()

momwe mungatsitsire tensrorflow, vuto ndi malangizo a avx

Onaninso zamatsenga !!! Tsopano zikuwoneka.

Ngati zonse zikuyenda bwino. Mukakhala ndi zonse zokonzeka, mutha kuyamba kugwiritsa ntchito ma Kera ndikusangalala ndi Kuphunzira Makina, kuphunzira mwakuya, luntha lochita kupanga, ...

Ndakhala ndi vuto lina lomwe lingachepetse kugwiritsa ntchito TensorFlow. Yang'anani chithunzicho ndipo muwona kuti mzere womaliza ndi Malangizo Osaloledwa ('core' opangidwa) mu Chingerezi ndiye maziko omwe adatayidwa.

Vuto ndi malangizo a TensorFlow ndi AVX. TensorFlow yatayidwa

Zikuwoneka kuti mitundu ya TensorFlow yomwe idakonzedweratu yoposa 1.5 imagwiritsa ntchito malangizo a AVX omwe sagwirizana ndi ma CPU akale. Nditafufuza ndikufufuza, yankho lokhalo lomwe ndidapeza linali pa stackoverflow, pomwe adati tiyenera kukhala pa mtundu 1.5

Chifukwa chake ndimayenera kutsitsa kuchokera ku TensorFlow kupita ku 1.5 Ngati muli ndi vuto lomweli

pip kukhazikitsa tensorflow == 1.5

Ndipo tsopano?

Chinthu choyamba ndikuyesa Keras, momwe imagwirira ntchito, ngati ndiyimitsa kapena ayi. Ngati ndingoyesa mayeso kapena ngati ndigwiritsa ntchito chowonadi pamavuto. Chowonadi ndichakuti Keras ndiosiyana kotheratu ndi momwe ndidagwiritsira ntchito Octave / Matlab mu Machine Learning course. Ndi Keras, ndikuti zikuwoneka kuti ma algorithms samawawona konse, mwawaika kale ndikudzipereka kuti muwasanjike. Ndikapitiliza nazo kuphunzira makina, ndipo ndikufuna chida champhamvu kwambiri mwina ndimasankha ntchito zamtambo pomwe Keras amakonzedweratu monga AWS, Azure, google mtambo, ndi zina zambiri.

Koma ndimasiya izi mtsogolo. Ndimapita pang'onopang'ono.

Fuentes:

Kusiya ndemanga