{"id":54494,"date":"2019-12-27T00:00:00","date_gmt":"2019-12-26T21:00:00","guid":{"rendered":"https:\/\/prohoster.info\/blog\/blog_prohoster\/dzhedajskaya-tehnika-umensheniya-svertochnyh-setej-pruning"},"modified":"2020-02-18T14:02:30","modified_gmt":"2020-02-18T11:02:30","slug":"dzhedajskaya-tehnika-umensheniya-svertochnyh-setej-pruning","status":"publish","type":"post","link":"https:\/\/prohoster.info\/sq\/blog\/news\/dzhedajskaya-tehnika-umensheniya-svertochnyh-setej-pruning","title":{"rendered":"Teknika Jedi e reduktimit t\u00eb rrjeteve konvoluese \u2014 pruning","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><img decoding=\"async\" alt=\"Teknika Jedi e reduktimit t\u00eb rrjeteve konvoluese \u2014 pruning\" src=\"\/wp-content\/uploads\/2019\/12\/cca85b86c64843707a2167a7fed19867.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Para ty p\u00ebrs\u00ebri \u00ebsht\u00eb nj\u00eb detyr\u00eb p\u00ebr identifikimin e objekteve. Prioriteti \u00ebsht\u00eb shpejt\u00ebsia e pun\u00ebs me nj\u00eb sakt\u00ebsi t\u00eb pranueshme. Merr arhitektur\u00ebn YOLOv3 dhe e trajnoni at\u00eb. Sakt\u00ebsia (mAp75) \u00ebsht\u00eb m\u00eb shum\u00eb se 0.95. Por shpejt\u00ebsia e p\u00ebrpunimit gjithmon\u00eb mbetet e ul\u00ebt. Korr. <\/p>\n<p><\/p>\n<p>Sot do ta kalojm\u00eb n\u00eb m\u00ebnyr\u00eb anash kvanitizimin. N\u00ebn kapitujm do t\u00eb shqyrtojm\u00eb <strong>Pruning i Modelit<\/strong> \u2014 prerja e pjes\u00ebve t\u00eb tep\u00ebrta t\u00eb rrjetit p\u00ebr t\u00eb p\u00ebrshpejtuar Inferenc\u00ebn pa humbur sakt\u00ebsin\u00eb. Duke e ilustruar \u2014 nga e ku, sa dhe si mund t\u00eb hiqet. Do t\u00eb diskutojm\u00eb se si ta b\u00ebjm\u00eb k\u00ebt\u00eb manualisht dhe ku mund ta automatizojm\u00eb. N\u00eb fund \u2014 nj\u00eb depo n\u00eb keras.<\/p>\n<p><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h3 id=\"vvedenie\">Hyrje<\/h3>\n<p><\/p>\n<p>N\u00eb vendin tim t\u00eb kaluar t\u00eb pun\u00ebs, n\u00eb Macroscopin e Perm\u00ebs, kam fituar nj\u00eb zakon \u2014 t\u00eb monitoroj gjithmon\u00eb koh\u00ebn e ekzekutimit t\u00eb algoritmeve. Dhe koh\u00ebn e p\u00ebrpunimit t\u00eb rrjeteve gjithmon\u00eb ta kontrolloj p\u00ebrmes filtrit t\u00eb adekuat\u00ebsis\u00eb. Zakonisht, state-of-the-art n\u00eb prodhim nuk kalojn\u00eb k\u00ebt\u00eb filt\u00ebr, q\u00eb m\u00eb \u00e7oi tek Pruning. <\/p>\n<p><\/p>\n<p>Pruning \u2014 nj\u00eb tem\u00eb e vjet\u00ebr, p\u00ebr t\u00eb cil\u00ebn flitej n\u00eb <noindex><a rel=\"nofollow\" href=\"https:\/\/www.youtube.com\/watch?v=eZdOkDtYMoo\">lektorat e Stanfordit<\/a><\/noindex> n\u00eb vitin 2017. Ideja kryesore \u2014 reduktimi i madh\u00ebsis\u00eb s\u00eb rrjetit t\u00eb trajnuar pa humbur sakt\u00ebsin\u00eb p\u00ebrmes heqjes s\u00eb nyjave t\u00eb ndryshme. D\u00ebgjohet mir\u00eb, por rrall\u00eb d\u00ebgjoj p\u00ebr aplikimin e saj. Ndoshta mungojn\u00eb implementimet, nuk ka artikuj n\u00eb gjuh\u00ebn ruse ose thjesht t\u00eb gjith\u00eb e konsiderojn\u00eb pruning si nj\u00eb know-how dhe heshtin.<br \/>\nPor le t'i hedhim nj\u00eb v\u00ebshtrim<\/p>\n<p><\/p>\n<h3 id=\"vzglyad-v-biologiyu\">Nj\u00eb v\u00ebshtrim n\u00eb biologji<\/h3>\n<p><\/p>\n<p>M\u00eb p\u00eblqen kur n\u00eb Deep Learning hyjn\u00eb ide nga biologjia. Ata, ashtu si dhe evolucionin, mund t\u00eb besohen (a e more vesh se ReLU \u00ebsht\u00eb shum\u00eb e ngjashme me <noindex><a rel=\"nofollow\" href=\"http:\/\/www.gatsby.ucl.ac.uk\/~lmate\/biblio\/dayanabbott.pdf\">funksionin e aktivizimit t\u00eb neuroneve n\u00eb tru<\/a><\/noindex>?) <\/p>\n<p><\/p>\n<p>Procesi i Pruning t\u00eb Modelit \u00ebsht\u00eb gjithashtu i af\u00ebrt me biologjin\u00eb. Reagimi i rrjetit k\u00ebtu mund t\u00eb krahasohet me plastizitetin e trurit. Ka disa shembuj interesant\u00eb n\u00eb librin <noindex><a rel=\"nofollow\" href=\"https:\/\/www.litres.ru\/norman-doydzh\/plastichnost-mozga\/?utm_medium=cpc&amp;utm_source=google&amp;utm_campaign=DSA%7C149839530&amp;utm_term=&amp;utm_content=k50id%7Caud-499675211712%3Adsa-179513627318%7Ccid%7C149839530%7Caid%7C248455294996%7Cgid%7C6837176850%7Cpos%7C1t1%7Csrc%7Cg_%7Cdvc%7Cc%7Creg%7C1011993%7Crin%7C%7C&amp;k50id=6837176850%7Caud-499675211712%3Adsa-179513627318&amp;gclid=Cj0KCQiA0ZHwBRCRARIsAK0Tr-oKPqkmL7_Oxg62JZO8Jlk9zO-9nYKIRFxHi_lgoCvsQQadvUGxUzkaApgpEALw_wcB\">Norman Doidge<\/a><\/noindex>:<\/p>\n<p><\/p>\n<ol>\n<li>Truri i nj\u00eb gruaje q\u00eb kishte prej lindjes vet\u00ebm nj\u00eb gjysm\u00eb, e riprogramoi vetveten p\u00ebr t\u00eb kryer funksionet e gjysm\u00ebs s\u00eb munguar<\/li>\n<li>Nj\u00eb djal\u00eb q\u00eb i ka shk\u00ebputur vetes pjes\u00ebn e trurit q\u00eb p\u00ebrgjigjej p\u00ebr shikimin. Me kalimin e koh\u00ebs, pjes\u00eb t\u00eb tjera t\u00eb trurit mor\u00ebn p\u00ebrsip\u00ebr k\u00ebto funksione. (nuk po e p\u00ebrs\u00ebrisim)<\/li>\n<\/ol>\n<p><\/p>\n<p>Ashtu si nga modeli juaj mund t\u00eb hiqni disa nga konvolucionet e dob\u00ebta. N\u00eb rastin m\u00eb t\u00eb keq, konvolucionet e mbetura do t'ju ndihmojn\u00eb t\u00eb z\u00ebvend\u00ebsoni t\u00eb hequrat. <\/p>\n<p><\/p>\n<h3 id=\"lyubish-transfer-learning-ili-uchish-s-nulya\">A e do Transfer Learning apo m\u00ebson nga fillimi?<\/h3>\n<p><\/p>\n<p><strong>Opsioni num\u00ebr nj\u00eb.<\/strong> Po p\u00ebrdor Transfer Learning n\u00eb Yolov3, Retina, Mask-RCNN ose U-Net. Por shpesh nuk na nevojitet t\u00eb njohim 80 klasa objektesh si n\u00eb COCO. N\u00eb p\u00ebrvoj\u00ebn time, gjith\u00e7ka \u00ebsht\u00eb e kufizuar n\u00eb 1-2 klasa. Mund t\u00eb supozojm\u00eb se arkitektura p\u00ebr 80 klasa k\u00ebtu \u00ebsht\u00eb e tep\u00ebrt. Kjo na b\u00ebn t\u00eb mendojm\u00eb se arkitektura duhet t\u00eb zvog\u00eblohet. P\u00ebr m\u00eb tep\u00ebr, do t\u00eb d\u00ebshironim ta b\u00ebnim k\u00ebt\u00eb pa humbur pesha e paratreguara ekzistuese.<\/p>\n<p><\/p>\n<p><strong>Opsioni i dyt\u00eb.<\/strong> Ndoshta ti ke shum\u00eb t\u00eb dh\u00ebna dhe burime kompjuterike, ose thjesht t\u00eb nevojitet nj\u00eb arkitektur\u00eb super-personalizuar. Nuk ka r\u00ebnd\u00ebsi. Por ti e m\u00ebson rrjetin nga e para. Rregulli i zakonsh\u00ebm \u00ebsht\u00eb q\u00eb shohim struktur\u00ebn e t\u00eb dh\u00ebnave, p\u00ebrzgjedhim nj\u00eb arkitektur\u00eb TEP\u00cbR t\u00eb fuqishme dhe shtojm\u00eb dropaout p\u00ebr mbipopullimin. Kam par\u00eb dropaout 0.6, Karl. <\/p>\n<p><\/p>\n<p>N\u00eb t\u00eb dy rastet, rrjeti mund t\u00eb zvog\u00eblohet. E kemi motivuar. Tani le t\u00eb kuptojm\u00eb se \u00e7far\u00eb \u00ebsht\u00eb prerja (pruning).<\/p>\n<p><\/p>\n<h3 id=\"obschiy-algoritm\">Algoritmi i p\u00ebrgjithsh\u00ebm<\/h3>\n<p><\/p>\n<p>Kemi vendosur se mund t\u00eb eliminojm\u00eb konvolucione. Duke dukur mjaft e thjesht\u00eb:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Teknika Jedi e reduktimit t\u00eb rrjeteve konvoluese \u2014 pruning\" src=\"\/wp-content\/uploads\/2019\/12\/1c01fa318d08550c9738c88d52e36b2d.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Eliminimi i \u00e7do konvolucioni \u00ebsht\u00eb nj\u00eb stres p\u00ebr rrjetin, i cili zakonisht \u00e7on n\u00eb nj\u00eb rritje t\u00eb caktuar t\u00eb gabimit. Nga nj\u00ebra an\u00eb, kjo rritje e gabimit \u00ebsht\u00eb nj\u00eb tregues se sa sakt\u00eb po eliminojm\u00eb konvolucionet (p.sh., nj\u00eb rritje e madhe tregon se po b\u00ebjm\u00eb di\u00e7ka gabim). Por nj\u00eb rritje e vog\u00ebl \u00ebsht\u00eb mjaft e pranueshme dhe shpesh hiqet me nj\u00eb rit\u00ebm t\u00eb vog\u00ebl t\u00eb p\u00ebrshtatjes q\u00eb vijon. Shtojm\u00eb nj\u00eb hap p\u00ebrshtatjeje:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Teknika Jedi e reduktimit t\u00eb rrjeteve konvoluese \u2014 pruning\" src=\"\/wp-content\/uploads\/2019\/12\/d51df9606d65fd4e7e80209743f761c3.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Tani na nevojitet t\u00eb kuptojm\u00eb se kur duam t\u00eb ndalojm\u00eb ciklin ton\u00eb t\u00eb M\u00ebsimitPruning. K\u00ebtu mund t\u00eb ken\u00eb variante ekzotike, kur duhet ta zvog\u00eblojm\u00eb rrjetin n\u00eb nj\u00eb madh\u00ebsi dhe shpejt\u00ebsi t\u00eb caktuar (p.sh., p\u00ebr pajisje mobile). Megjithat\u00eb, varianti m\u00eb i zakonsh\u00ebm \u00ebsht\u00eb vazhdimi i ciklit derisa gabimi t\u00eb shkoj\u00eb mbi maksimumin e pranuesh\u00ebm. Shtojm\u00eb nj\u00eb kushte:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Teknika Jedi e reduktimit t\u00eb rrjeteve konvoluese \u2014 pruning\" src=\"\/wp-content\/uploads\/2019\/12\/9032018847833b54402124a29d3acbb1.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Pra, algoritmi b\u00ebhet i qart\u00eb. Ne duhet t\u00eb p\u00ebrcaktojm\u00eb se si t\u00eb identifikojm\u00eb konvolucionet p\u00ebr tu eliminuar.<\/p>\n<p><\/p>\n<h3 id=\"poisk-udalyaemyh-svertok\">K\u00ebrkimi i konvolucioneve p\u00ebr t'u eliminuar.<\/h3>\n<p><\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0441\u0432\u0435\u0440\u0442\u043a\u0438. \u0420\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u043f\u0440\u043e\u043b\u043e\u043c \u0438 &#171;\u043e\u0442\u0441\u0442\u0440\u0435\u043b\u0438\u0432\u0430\u0442\u044c&#187; \u043b\u044e\u0431\u044b\u0435 \u2014 \u043f\u043b\u043e\u0445\u0430\u044f \u0438\u0434\u0435\u044f, \u0445\u043e\u0442\u044c \u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041d\u043e \u0440\u0430\u0437 \u0435\u0441\u0442\u044c \u0433\u043e\u043b\u043e\u0432\u0430, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f &#171;\u0441\u043b\u0430\u0431\u044b\u0435&#187; \u0441\u0432\u0435\u0440\u0442\u043a\u0438. \u0412\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e:<\/p>\n<p><\/p>\n<ol>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/openreview.net\/pdf?id=rJqFGTslg\">Masa m\u00eb e vog\u00ebl L1 ose low_magnitude_pruning.<\/a><\/noindex>. Ideja \u00ebsht\u00eb se konvolucionet me k\u00ebto vlera t\u00eb vogla peshojn\u00eb pak n\u00eb vendimin p\u00ebrfundimtar. <\/li>\n<li>Masa m\u00eb e vog\u00ebl L1 me llogaritjen e mesatares dhe devijimit standard. Plot\u00ebsojm\u00eb me vler\u00ebsimin e natyr\u00ebs s\u00eb shp\u00ebrndarjes.<\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/arxiv.org\/abs\/1512.08571\">Maskimi i konvolutioneve dhe p\u00ebrjashtimi i atyre me ndikimin m\u00eb t\u00eb vog\u00ebl n\u00eb sakt\u00ebsin\u00eb p\u00ebrfundimtare<\/a><\/noindex>. Nj\u00eb p\u00ebrcaktim m\u00eb i sakt\u00eb i konvolutioneve t\u00eb pakta, por shum\u00eb i kushtuesh\u00ebm n\u00eb koh\u00eb dhe resurse. <\/li>\n<li>T\u00eb tjera <\/li>\n<\/ol>\n<p><\/p>\n<p>\u00c7do opsion ka t\u00eb drejt\u00ebn e ekzistenc\u00ebs dhe karakteristikat e tij t\u00eb ve\u00e7anta. K\u00ebtu do t\u00eb shqyrtojm\u00eb opsionin me mas\u00ebn L1 m\u00eb t\u00eb vog\u00ebl<\/p>\n<p><\/p>\n<h3 id=\"ruchnoy-process-dlya-yolov3\">Procesi manual p\u00ebr YOLOv3<\/h3>\n<p><\/p>\n<p>Arkitektura origjinale p\u00ebrmban blloqe reziduese. Por, pavar\u00ebsisht sa t\u00eb jasht\u00ebzakonsh\u00ebm jan\u00eb ata p\u00ebr rrjetet e thella, ata na krijojn\u00eb disa pengesa. V\u00ebshtir\u00ebsia \u00ebsht\u00eb se nuk mund t\u00eb fshihen konvolutionet me indekse t\u00eb ndryshme n\u00eb k\u00ebto shtresa:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Teknika Jedi e reduktimit t\u00eb rrjeteve konvoluese \u2014 pruning\" src=\"\/wp-content\/uploads\/2019\/12\/d516ab886a28d62a34e6a934fdd62c12.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Prandaj, do t\u00eb distintim shtresat nga t\u00eb cilat mund t\u00eb fshijm\u00eb lirisht konvolutionet:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Teknika Jedi e reduktimit t\u00eb rrjeteve konvoluese \u2014 pruning\" src=\"\/wp-content\/uploads\/2019\/12\/f9b69d9900d641e1d5835db9cc749189.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Tani do t\u00eb ngrem\u00eb nj\u00eb cik\u00ebl pune:<\/p>\n<p><\/p>\n<ol>\n<li>Shkarkojm\u00eb aktivizimet<\/li>\n<li>P\u00ebrllogarisim se sa t\u00eb presim <\/li>\n<li>Presim<\/li>\n<li>M\u00ebsojm\u00eb p\u00ebr 10 epoka me LR=1e-4 <\/li>\n<li>Testojm\u00eb <\/li>\n<\/ol>\n<p><\/p>\n<p>Shkarkimi i konvolutioneve \u00ebsht\u00eb i dobish\u00ebm p\u00ebr t\u00eb vler\u00ebsuar se sa pjes\u00eb mund t\u00eb fshijm\u00eb n\u00eb nj\u00eb hap t\u00eb caktuar. Shembujt e shkarkimit:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Teknika Jedi e reduktimit t\u00eb rrjeteve konvoluese \u2014 pruning\" src=\"\/wp-content\/uploads\/2019\/12\/cd8202e6ce1aa0cc59fbdc4bd8562427.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>V\u00ebm\u00eb re se pothuajse kudo 5% e konvolutioneve kan\u00eb norm\u00eb shum\u00eb t\u00eb ul\u00ebt L1 dhe mund t'i fshijm\u00eb. N\u00eb \u00e7do hap, ky shkarkim p\u00ebrs\u00ebritej dhe b\u00ebhej vler\u00ebsimi se nga cilat shtresa dhe sa mund t\u00eb presim. <\/p>\n<p><\/p>\n<p>I gjith\u00eb procesi u zhvillua n\u00eb 4 hapa (k\u00ebtu dhe n\u00eb gjith\u00eb numrat p\u00ebr RTX 2060 Super):<\/p>\n<p><\/p>\n<table>\n<thead>\n<tr>\n<th>Hapi<\/th>\n<th>mAp75<\/th>\n<th>Numri i parametrave, mln<\/th>\n<th>Madh\u00ebsia e rrjetit, mb<\/th>\n<th>Nga origjinali, %<\/th>\n<th>Koha e kalimit, ms<\/th>\n<th>Kushti i prerjes<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>0<\/td>\n<td>0.9656<\/td>\n<td>60<\/td>\n<td>241<\/td>\n<td>100<\/td>\n<td>180<\/td>\n<td>\u2014<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>0.9622<\/td>\n<td>55<\/td>\n<td>218<\/td>\n<td>91<\/td>\n<td>175<\/td>\n<td>5% nga e gjith\u00eb<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>0.9625<\/td>\n<td>50<\/td>\n<td>197<\/td>\n<td>83<\/td>\n<td>168<\/td>\n<td>5% nga e gjith\u00eb<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>0.9633<\/td>\n<td>39<\/td>\n<td>155<\/td>\n<td>64<\/td>\n<td>155<\/td>\n<td>15% p\u00ebr shtresat me 400+ konvolucione<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>0.9555<\/td>\n<td>31<\/td>\n<td>124<\/td>\n<td>51<\/td>\n<td>146<\/td>\n<td>10% p\u00ebr shtresat me 100+ konvolucione<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/p>\n<p>N\u00eb hapin 2 u shtua nj\u00eb efekt pozitiv \u2014 q\u00eb madh\u00ebsia e grupit t\u00eb kishte 4, gj\u00eb q\u00eb p\u00ebrshpejtoi ndjesh\u00ebm procesin e rip\u00ebrshtatjes.<br \/>\nN\u00eb hapin 4 procesi u ndal, pasi edhe trajnimet e zgjatura nuk \u00e7uan mAp75 n\u00eb vlerat e vjetra.<br \/>\nN\u00eb fund, arrit\u00ebm t\u00eb shpejtojm\u00eb inferenc\u00ebn me <strong>15%<\/strong>, t\u00eb zvog\u00eblojm\u00eb madh\u00ebsin\u00eb me<strong> 35% <\/strong>dhe t\u00eb mos humbim sakt\u00ebsin\u00eb. <\/p>\n<p><\/p>\n<h3 id=\"avtomatizaciya-dlya-bolee-prostyh-arhitektur\">Automatizimi p\u00ebr arkitektur\u00eb m\u00eb t\u00eb thjesht\u00eb<\/h3>\n<p><\/p>\n<p>P\u00ebr arkitekturat m\u00eb t\u00eb thjeshta t\u00eb rrjeteve (pa blloqe t\u00eb mundshme add, concatenate dhe residual), \u00ebsht\u00eb e mundshme t\u00eb orientohesh n\u00eb p\u00ebrpunimin e t\u00eb gjitha shtresave konvolucionale dhe t\u00eb automatizosh procesin e prerjes s\u00eb konvolutioneve.<\/p>\n<p><\/p>\n<p>Ky opsion e implementova <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/PaginDm\/keras-L1-pruning\">k\u00ebtu<\/a><\/noindex>.<br \/>\nE gjith\u00eb \u00ebsht\u00eb e thjesht\u00eb: ju keni vet\u00ebm funksionin e humbjes, optimizuesin dhe gjenerator\u00ebt e grupit:<\/p>\n<p><\/p>\n<pre><code class=\"python\">import pruning\nfrom keras.optimizers import Adam\nfrom keras.utils import Sequence\n\ntrain_batch_generator = BatchGenerator...\nscore_batch_generator = BatchGenerator...\n\nopt = Adam(lr=1e-4)\npruner = pruning.Pruner(\"config.json\", \"categorical_crossentropy\", opt)\n\npruner.prune(train_batch, valid_batch)<\/code><\/pre>\n<p><\/p>\n<p>N\u00ebse \u00ebsht\u00eb e nevojshme, mund t\u00eb ndryshoni parametrat e konfigurimeve:<\/p>\n<p><\/p>\n<pre><code class=\"json\">{\n    \"input_model_path\": \"model.h5\",\n    \"output_model_path\": \"model_pruned.h5\",\n    \"finetuning_epochs\": 10, # numri i epokave p\u00ebr train midis hapave t\u00eb prerjes\n    \"stop_loss\": 0.1, # humbja p\u00ebr t\u00eb ndaluar procesin\n    \"pruning_percent_step\": 0.05, # pjesa e convs p\u00ebr t\u00eb fshir\u00eb n\u00eb \u00e7do hap prerjeje\n    \"pruning_standart_deviation_part\": 0.2 # shmangie p\u00ebr t\u00eb kufizuar pjes\u00ebn e prerjes\n}<\/code><\/pre>\n<p><\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044f. \u0426\u0435\u043b\u044c \u2014 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0443\u0434\u0430\u043b\u044f\u0435\u043c\u044b\u0445, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0441\u0432\u0435\u0440\u0442\u043a\u0438 \u0441 \u0443\u0436\u0435 &#171;\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u043c\u0438&#187; L1-\u043c\u0435\u0440\u0430\u043c\u0438:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Teknika Jedi e reduktimit t\u00eb rrjeteve konvoluese \u2014 pruning\" src=\"\/wp-content\/uploads\/2019\/12\/c2733d01a4d5b6e9a97a1e683d87ff45.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>K\u00ebshtu, ne lejojm\u00eb q\u00eb t\u00eb fshijm\u00eb vet\u00ebm konvolucionet e dob\u00ebta nga shp\u00ebrndarjet e ngjashme me ato t\u00eb djathta dhe nuk ndikojm\u00eb n\u00eb fshirjen nga shp\u00ebrndarjet e ngjashme me ato t\u00eb majta:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Teknika Jedi e reduktimit t\u00eb rrjeteve konvoluese \u2014 pruning\" src=\"\/wp-content\/uploads\/2019\/12\/a9c9bee6322d268026ffb6713fc0bc86.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Kur shp\u00ebrndarja i afrohet normalit, koeficienti pruning_standart_deviation_part mund t\u00eb p\u00ebrcaktohet nga:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Teknika Jedi e reduktimit t\u00eb rrjeteve konvoluese \u2014 pruning\" src=\"\/wp-content\/uploads\/2019\/12\/efee3eda6b8263de42e8f52541a3e949.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nUn\u00eb rekomandoj nj\u00eb toleranc\u00eb prej 2 sigma. Ose mund t\u00eb mos orientoheni nga kjo ve\u00e7ori, duke l\u00ebn\u00eb vler\u00ebn &lt; 1.0.<\/p>\n<p><\/p>\n<p>Si rezultat, del nj\u00eb grafik i madh\u00ebsis\u00eb s\u00eb rrjetit, humbjes dhe koh\u00ebs s\u00eb ekzekutimit t\u00eb rrjetit gjat\u00eb gjith\u00eb testit, t\u00eb normalizuar n\u00eb 1.0. P\u00ebr shembull, k\u00ebtu madh\u00ebsia e rrjetit u zvog\u00eblua gati 2 her\u00eb pa humbje n\u00eb cil\u00ebsi (nj\u00eb rrjet i vog\u00ebl konvolucional me 100k pesh\u00eb):<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Teknika Jedi e reduktimit t\u00eb rrjeteve konvoluese \u2014 pruning\" src=\"\/wp-content\/uploads\/2019\/12\/1048ac38b12c753e54c8d8a2dc1dc394.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Shpejt\u00ebsia e ekzekutimit \u00ebsht\u00eb e ekspozuar ndaj fluktuacioneve normale dhe praktikisht nuk ka ndryshuar. K\u00ebsaj i ka shpjegim:<\/p>\n<p><\/p>\n<ol>\n<li>Numri i konvolucioneve kalon nga t\u00eb p\u00ebrshtatshmet (32, 64, 128) n\u00eb ato q\u00eb nuk jan\u00eb aq t\u00eb p\u00ebrshtatshme p\u00ebr kartat grafike \u2014 27, 51 etj. K\u00ebtu mund t\u00eb gaboj, por besoj se kjo ndikon.<\/li>\n<li>Arkitektura nuk \u00ebsht\u00eb e gjer\u00eb, por e nj\u00ebpasnj\u00ebshme. Duke ulur gjer\u00ebsin\u00eb, ne nuk prekim thell\u00ebsin\u00eb. K\u00ebshtu zvog\u00eblojm\u00eb ngarkes\u00ebn, por nuk e ndryshojm\u00eb shpejt\u00ebsin\u00eb.<\/li>\n<\/ol>\n<p><\/p>\n<p>Prandaj, p\u00ebrmir\u00ebsimi u shpreh n\u00eb zvog\u00eblimin e ngarkes\u00ebs CUDA gjat\u00eb ekzekutimit p\u00ebr 20-30%, por jo n\u00eb zvog\u00eblimin e koh\u00ebs s\u00eb ekzekutimit.<\/p>\n<p><\/p>\n<h3 id=\"itogi\">P\u00ebrfundime<\/h3>\n<p><\/p>\n<p>Le t\u00eb reflektojm\u00eb. Kemi shqyrtuar 2 varianta t\u00eb prerjes \u2014 p\u00ebr YOLOv3 (kur duhet t\u00eb punosh me duar) dhe p\u00ebr rrjetet me arkitektura m\u00eb t\u00eb thjeshta. \u00cbsht\u00eb e qart\u00eb se n\u00eb t\u00eb dy rastet mund t\u00eb arrihet nj\u00eb zvog\u00eblim i madh\u00ebsis\u00eb s\u00eb rrjetit dhe nj\u00eb shpejt\u00ebsi m\u00eb e madhe pa humbje sakt\u00ebsie. Rezultatet:<\/p>\n<p><\/p>\n<ul>\n<li>Zvog\u00eblimi i madh\u00ebsis\u00eb<\/li>\n<li>Shpejtimi i ekzekutimit<\/li>\n<li>Zvog\u00eblimi i ngarkes\u00ebs CUDA<\/li>\n<li>Si pasoj\u00eb, ekologjiciteti (Ne optimizojm\u00eb p\u00ebrdorimin e ardhsh\u00ebm t\u00eb burimeve kompjuterike. Diku nj\u00ebra \u00ebsht\u00eb e g\u00ebzuar <noindex><a rel=\"nofollow\" href=\"https:\/\/meduza.io\/feature\/2019\/12\/12\/kto-takaya-greta-tunberg-i-pochemu-ona-stala-chelovekom-goda-zhurnal-time\">Greta Thunberg<\/a><\/noindex>)<\/li>\n<\/ul>\n<p><\/p>\n<h3 id=\"appendix\">Shtojca<\/h3>\n<p><\/p>\n<ul>\n<li>Pas hapit t\u00eb prerjes, mund t\u00eb vazhdojm\u00eb me kuantizimin (p\u00ebr shembull me TensorRT)<\/li>\n<li>Tensorflow ofron mund\u00ebsi p\u00ebr <noindex><a rel=\"nofollow\" href=\"https:\/\/www.tensorflow.org\/model_optimization\/guide\/pruning\/pruning_with_keras\">low_magnitude_pruning<\/a><\/noindex>. Funksionon.<\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/PaginDm\/keras-L1-pruning\">Repo<\/a><\/noindex> dua ta zhvilloj dhe do t\u00eb isha i lumtur p\u00ebr ndihm\u00eb<\/li>\n<\/ul>\n<p>Burimi: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/482050\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u043e\u0431\u043e\u0439 \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u2014 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u0411\u0435\u0440\u0435\u0448\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 YOLOv3 \u0438 \u0434\u043e\u043e\u0431\u0443\u0447\u0430\u0435\u0448\u044c. \u0422\u043e\u0447\u043d\u043e\u0441\u0442\u044c(mAp75) \u0431\u043e\u043b\u044c\u0448\u0435 0.95. \u041d\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u0432\u0441\u0451 \u0435\u0449\u0435 \u043d\u0438\u0437\u043a\u0430\u044f. \u0427\u0435\u0440\u0442. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043e\u0431\u043e\u0439\u0434\u0451\u043c \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439 \u043a\u0432\u0430\u043d\u0442\u0438\u0437\u0430\u0446\u0438\u044e. \u0410 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c Model Pruning \u2014 \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u0438\u0435 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u0441\u0435\u0442\u0438 \u0434\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f Inference \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u041d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u2014 \u043e\u0442\u043a\u0443\u0434\u0430, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438 \u043a\u0430\u043a [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[702],"tags":[],"class_list":["post-54494","post","type-post","status-publish","format-standard","hentry","category-news"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041f\u0435\u0440\u0435\u0434 \u0442\u043e\u0431\u043e\u0439 \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u0434\u0430\u0447\u0430.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/sq\/blog\/news\/dzhedajskaya-tehnika-umensheniya-svertochnyh-setej-pruning\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"sq_AL\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u0414\u0436\u0435\u0434\u0430\u0439\u0441\u043a\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0441\u0432\u0435\u0440\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 \u2014 pruning | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041f\u0435\u0440\u0435\u0434 \u0442\u043e\u0431\u043e\u0439 \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u0434\u0430\u0447\u0430.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/sq\/blog\/news\/dzhedajskaya-tehnika-umensheniya-svertochnyh-setej-pruning\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-12-26T21:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-02-18T11:02:30+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Teknika Jedi e zvog\u00eblimit t\u00eb rrjeteve konvolucionale \u2014 pruning | ProHoster","description":"Nj\u00ebher\u00eb tjet\u00ebr, keni nj\u00eb detyr\u00eb.","canonical_url":"https:\/\/prohoster.info\/sq\/blog\/news\/dzhedajskaya-tehnika-umensheniya-svertochnyh-setej-pruning","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"sq_AL","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u0414\u0436\u0435\u0434\u0430\u0439\u0441\u043a\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0441\u0432\u0435\u0440\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 \u2014 pruning | ProHoster","og:description":"\u041f\u0435\u0440\u0435\u0434 \u0442\u043e\u0431\u043e\u0439 \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u0434\u0430\u0447\u0430.","og:url":"https:\/\/prohoster.info\/sq\/blog\/news\/dzhedajskaya-tehnika-umensheniya-svertochnyh-setej-pruning","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-12-26T21:00:00+00:00","article:modified_time":"2020-02-18T11:02:30+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"54494","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-24 11:34:22","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 12:29:04","updated":"2026-01-24 11:34:22","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/54494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/comments?post=54494"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/54494\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/media?parent=54494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/categories?post=54494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/tags?post=54494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}