joaopauloschuler / neural-api

CAI NEURAL API - Pascal based deep learning neural network API optimized for AVX, AVX2 and AVX512 instruction sets plus OpenCL capable devices including AMD, Intel and NVIDIA.
GNU Lesser General Public License v2.1
356 stars 195 forks source link

Hypotenuse, Randomize and Delphi #79

Closed Kryuski closed 2 years ago

Kryuski commented 2 years ago

While studying the Hypotenuse example program in Delphi, I found out that it cannot train the neural network at all. After 50 epochs, NN returned 0 for any input parameters:

Inputs:98.00, 55.00 - Output: 0.00  Desired Output:112.38
Inputs:29.00, 91.00 - Output: 0.00  Desired Output:95.51
Inputs:96.00, 53.00 - Output: 0.00  Desired Output:109.66
Inputs:80.00, 94.00 - Output: 0.00  Desired Output:123.43
Inputs:97.00, 18.00 - Output: 0.00  Desired Output:98.66
Inputs:85.00, 66.00 - Output: 0.00  Desired Output:107.62
Inputs:47.00, 71.00 - Output: 0.00  Desired Output:85.15
Inputs:19.00, 96.00 - Output: 0.00  Desired Output:97.86
Inputs:68.00, 53.00 - Output: 0.00  Desired Output:86.21
Inputs:74.00, 14.00 - Output: 0.00  Desired Output:75.31

I tried to debug but without result. Finally I tried to add Randomize before creating the network and voila! Just after 10 epochs, a network with a good degree of approximation was built:

Inputs:98.00, 55.00 - Output:111.94  Desired Output:112.38
Inputs:29.00, 91.00 - Output:95.19  Desired Output:95.51
Inputs:96.00, 53.00 - Output:109.29  Desired Output:109.66
Inputs:80.00, 94.00 - Output:123.39  Desired Output:123.43
Inputs:97.00, 18.00 - Output:98.88  Desired Output:98.66
Inputs:85.00, 66.00 - Output:107.60  Desired Output:107.62
Inputs:47.00, 71.00 - Output:84.92  Desired Output:85.15
Inputs:19.00, 96.00 - Output:98.01  Desired Output:97.86
Inputs:68.00, 53.00 - Output:86.21  Desired Output:86.21
Inputs:74.00, 14.00 - Output:75.48  Desired Output:75.31

I don't know if this library is not fully compatible with Delphi, or the initial weights of the network did not allow it to be trained by this method. If you are interested, here are the initial parameters of the network, which cannot be trained:

-1)TNNetInput:2;1;1;0;0;0;0;0#0)TNNetFullConnectReLU:32;1;1;0;0;0;0;0#1)TNNetFullConnectReLU:32;1;1;0;0;0;0;0#2)TNNetFullConnectReLU:1;1;1;0;0;0;0;0
!0]1;2;1;1;-0.420084029436111;-0.393786758184433[0]1;2;1;1;0.303300678730011;-0.249950006604195[0]1;2;1;1;-0.190802171826363;0.144172832369804[0]1;2;1;1;-0.152406483888626;-0.284228831529617[0]1;2;1;1;-0.107373483479023;-0.0625085011124611[0]1;2;1;1;-0.351190268993378;-0.0212562512606382[0]1;2;1;1;-0.360852181911469;0.28632926940918[0]1;2;1;1;-0.369925975799561;-0.17374674975872[0]1;2;1;1;0.350518107414246;-0.110986202955246[0]1;2;1;1;0.23071014881134;-0.14459291100502[0]1;2;1;1;0.166017219424248;0.289101839065552[0]1;2;1;1;0.183072611689568;-0.162488505244255[0]1;2;1;1;-0.283472687005997;-0.143332675099373[0]1;2;1;1;-0.0285657159984112;-0.212898582220078[0]1;2;1;1;0.273558706045151;-0.185677140951157[0]1;2;1;1;-0.0153750758618116;-0.294814974069595[0]1;2;1;1;0.314474910497665;-0.178787752985954[0]1;2;1;1;0.229113832116127;0.40025606751442[0]1;2;1;1;-0.00630126008763909;0.325901180505753[0]1;2;1;1;0.274902999401093;-0.40311262011528[0]1;2;1;1;-0.301620334386826;-0.299519926309586[0]1;2;1;1;0.000672134454362094;-0.401936382055283[0]1;2;1;1;0.0780516117811203;-0.412018418312073[0]1;2;1;1;0.230542108416557;0.126529306173325[0]1;2;1;1;0.227181434631348;0.174838975071907[0]1;2;1;1;0.0483096651732922;-0.247009411454201[0]1;2;1;1;0.152070418000221;0.0779675915837288[0]1;2;1;1;0.382612526416779;0.120984196662903[0]1;2;1;1;0.418655723333359;-0.215335071086884[0]1;2;1;1;0.147953599691391;-0.171730354428291[0]1;2;1;1;-0.347997605800629;0.228777766227722[0]1;2;1;1;-0.00403280695900321;0.320608139038086!0]1;32;1;1;0.00606248714029789;0.0448868982493877;0.277465969324112;0.113166429102421;-0.098775677382946;-0.301532179117203;0.12572006881237;0.299388885498047;0.167790040373802;0.152786925435066;-0.185120195150375;-0.218249559402466;0.253216028213501;0.173975005745888;0.0546236224472523;0.223332226276398;0.11592210829258;-0.129945442080498;-0.24886816740036;0.0789348110556602;-0.13472193479538;0.230925649404526;-0.207471802830696;-0.138947308063507;0.0266994386911392;0.282119989395142;-0.199449717998505;-0.210043743252754;-0.142009183764458;-0.197551354765892;0.0469689704477787;-0.00116350769530982[0]1;32;1;1;-0.131598845124245;-0.210717365145683;0.0671772584319115;0.146724447607994;0.150888577103615;-0.257012724876404;-0.259462207555771;-0.269627571105957;-0.240968555212021;0.180956065654755;0.187263488769531;-0.0725049003958702;0.0685857161879539;-0.0387019366025925;0.147459283471107;-0.0037354719825089;-0.0972447469830513;0.195224344730377;0.194122076034546;-0.219658002257347;-0.248990640044212;-0.265096038579941;-0.269321411848068;-0.187447220087051;0.105879202485085;-0.166932731866837;0.0430497825145721;-0.150398671627045;-0.0821803882718086;0.206369519233704;-0.113595090806484;-0.113411381840706[0]1;32;1;1;0.0957750529050827;0.117697991430759;0.246724873781204;-0.11108436435461;-0.0131047712638974;-0.124679036438465;0.163319736719131;0.14727558195591;0.0317821316421032;0.136865243315697;-0.0541337244212627;0.0257196426391602;0.0586652792990208;0.233007714152336;0.103429704904556;-0.237416803836823;-0.017330139875412;-0.0590327046811581;-0.235947117209435;-0.273240596055984;0.0297613013535738;0.106185384094715;-0.256767779588699;0.258237451314926;0.207410544157028;0.11108436435461;0.261483043432236;-0.136436581611633;0.122964389622211;0.143540099263191;-6.12372459727339E-5;0.100245371460915[0]1;32;1;1;-0.209308907389641;-0.165340572595596;0.273424297571182;-0.0827315226197243;-0.22859862446785;0.298164159059525;-0.118677787482738;-0.272873163223267;-0.243785470724106;0.224495753645897;0.0333130620419979;0.120698608458042;-0.244581550359726;0.10336846858263;-0.296082079410553;-0.116473242640495;0.247520938515663;0.0215555112808943;-0.10594043135643;-0.035272654145956;0.245316401124001;-0.0936317443847656;-0.0895900949835777;-0.0074709439650178;-0.262401610612869;0.214820265769958;0.159400552511215;-0.195775479078293;0.258911073207855;-0.00398042099550366;-0.228108748793602;0.240233719348907[0]1;32;1;1;-0.0592776536941528;-0.179118931293488;0.188059583306313;0.0535213500261307;-0.238947719335556;0.0754442885518074;0.261850446462631;0.0248010847717524;-0.106491565704346;-0.0316596552729607;-0.1673613935709;-0.193142279982567;0.116595715284348;0.303736746311188;0.0794247090816498;0.117330558598042;0.0249235592782497;-0.246663615107536;0.151317238807678;-0.215126439929008;-0.163564682006836;0.232885241508484;0.13086399435997;-0.0374771952629089;0.294122487306595;-0.211635932326317;-0.282119989395142;-0.193325981497765;-0.30030745267868;-0.0742195472121239;-0.0643603429198265;-0.0834051296114922[0]1;32;1;1;-0.255849212408066;-0.0282916072756052;0.00287815043702722;-0.0241887141019106;0.107410132884979;0.194428250193596;0.0409064777195454;-0.151072293519974;-0.0781999602913857;0.0505819618701935;0.229211017489433;0.0660749897360802;-0.148745268583298;0.12057613581419;0.0353338904678822;0.231905445456505;-0.0852422490715981;-0.0833438858389854;0.0744644924998283;0.171464294195175;-0.0263320170342922;-0.180466160178185;0.121372222900391;0.206491976976395;0.154195383191109;0.246051251888275;-0.192040011286736;0.168708607554436;-0.14243783056736;-0.125291407108307;0.124189138412476;-0.0263932533562183[0]1;32;1;1;0.284263283014297;-0.190815255045891;-0.29871529340744;-0.168708607554436;0.244397848844528;-0.108512401580811;0.222229957580566;0.161115199327469;0.285732984542847;-0.138212472200394;-0.0636867359280586;0.205818384885788;-0.293448895215988;-0.15499147772789;-0.273914188146591;0.00465403078123927;-0.0473363883793354;-0.306002527475357;-0.214269131422043;0.128108307719231;-0.114881075918674;-0.064115397632122;0.0291489288210869;-0.146418258547783;-0.213717997074127;-0.126822337508202;-0.259094774723053;0.125903770327568;-0.103919602930546;0.177098125219345;0.0949789732694626;0.0404165834188461[0]1;32;1;1;0.242621973156929;-0.292897760868073;-0.149480119347572;0.235702157020569;0.112982712686062;-0.286406606435776;-0.209431380033493;-0.210962310433388;-0.0533376410603523;-0.0497246459126472;-0.218249559402466;-0.303920447826385;0.0181262250989676;0.160564050078392;0.0430497825145721;-0.164911910891533;0.221923768520355;-0.268280386924744;-0.00912434980273247;-0.260258287191391;-0.081445537507534;0.1004903241992;-0.180098727345467;0.185977518558502;0.0129822958260775;-0.0498471185564995;-0.282181233167648;0.301287263631821;-0.207900449633598;-0.277772128582001;-0.270178735256195;-0.244152903556824[0]1;32;1;1;0.185793817043304;0.278262048959732;-0.235702157020569;-0.17556719481945;0.161360144615173;0.294000029563904;-0.00165340572129935;-0.286529064178467;0.0573180615901947;0.185058951377869;0.258604884147644;0.00679733417928219;0.0979795902967453;0.305880039930344;0.164728194475174;0.13214997947216;0.241335988044739;0.303001880645752;0.142499074339867;0.172382861375809;-0.295959621667862;-0.0820579081773758;-0.110410749912262;-0.260442018508911;0.173668831586838;-0.146908149123192;0.217392221093178;0.255971699953079;-0.276547402143478;0.241458475589752;0.259768396615982;-0.00716475769877434[0]1;32;1;1;0.115738391876221;-0.0747094377875328;-0.0477650538086891;0.151011049747467;0.120025001466274;-0.0973672196269035;0.0792409926652908;0.00606248714029789;0.287080198526382;-0.244336605072021;0.300184994935989;-0.291428059339523;0.0712801590561867;-0.0881204009056091;0.00642991065979004;0.0895900949835777;0.189957946538925;0.0832214206457138;0.276547402143478;-0.000979795935563743;-0.00900187529623508;0.303736746311188;-0.159767970442772;-0.184446588158607;-0.0382120385766029;0.11592210829258;0.158604472875595;-0.286529064178467;0.0690143778920174;0.183895453810692;-0.0218616966158152;-0.203123942017555[0]1;32;1;1;0.082364097237587;-0.260442018508911;0.283099800348282;0.175934597849846;0.226639047265053;-0.0426823608577251;-0.302695721387863;-0.170423254370689;0.0472139157354832;0.23423245549202;-0.270301192998886;-0.0157992094755173;0.264177471399307;0.226516559720039;0.220209136605263;0.135518029332161;0.29467362165451;-0.175995841622353;-0.211819633841515;0.098775677382946;0.199082285165787;-0.190019175410271;-0.295653432607651;0.193815886974335;0.0371710062026978;-0.0190447829663754;-0.0372934825718403;-0.215065211057663;0.183650493621826;0.2282924503088;-0.247643411159515;0.0601349771022797[0]1;32;1;1;0.183344319462776;-0.173240169882774;-0.0156154977157712;-0.0589102283120155;0.00116350769530982;0.124801501631737;0.172015428543091;-0.11286024749279;-0.284691959619522;0.064115397632122;-0.127434715628624;-0.270301192998886;-0.0210043750703335;-0.17170923948288;-0.254563212394714;0.0952851548790932;0.21782086789608;-0.0962037146091461;-0.119167678058147;-0.0176975633949041;0.254930645227432;0.13680399954319;-0.0549910478293896;-0.254746943712234;0.188916891813278;-0.151868373155594;-0.283957093954086;-0.0931418463587761;0.235640913248062;0.220882758498192;-0.0382120385766029;-0.152664452791214[0]1;32;1;1;-0.0481324717402458;-0.0804045051336288;0.0921620577573776;-0.0429273098707199;0.0831601843237877;0.158053338527679;0.191550105810165;-0.0270668622106314;0.0229027289897203;0.0709739699959755;-0.117759227752686;-0.159155607223511;-0.0562157891690731;0.137355133891106;0.0952851548790932;-0.196326613426208;0.281936258077621;-0.284508228302002;-0.108022503554821;0.24164217710495;-0.0200245790183544;0.00851197727024555;0.23117059469223;0.10594043135643;-0.0522353686392307;0.0504594929516315;-0.217575937509537;0.290938168764114;-0.0181874614208937;-0.212187066674232;-0.114513650536537;0.0696267485618591[0]1;32;1;1;0.193693414330482;-0.0102266194298863;-0.223393470048904;-0.0214330367743969;-0.217882126569748;-0.103797130286694;0.0993880555033684;0.197000220417976;0.218555733561516;-0.210962310433388;-0.197980016469955;0.151317238807678;-0.13729390501976;-0.0955301076173782;-0.15450157225132;-0.282364934682846;0.245071470737457;0.116105824708939;-0.256951481103897;0.100429087877274;-0.297306835651398;0.0727498456835747;0.0499083548784256;0.165830463171005;-0.188978150486946;0.241703405976295;0.190754026174545;0.0867119356989861;-0.00765465572476387;0.172321602702141;0.151562184095383;-0.189100623130798[0]1;32;1;1;-0.0746482014656067;0.248439505696297;0.0162278693169355;0.229272246360779;0.139437198638916;-0.123270571231842;0.0572568252682686;-0.239682585000992;-0.0952239111065865;-0.0900187492370605;-0.0473363883793354;0.0450093746185303;0.253338485956192;0.109614670276642;0.145683407783508;0.303430557250977;-0.086895652115345;-0.247888371348381;-0.0610535331070423;-0.136436581611633;0.258788615465164;-0.161605104804039;-0.0686469525098801;-0.256829023361206;0.0174526143819094;0.00845074001699686;0.0227802563458681;-0.168953567743301;-0.186406180262566;-0.051990419626236;0.287753820419312;0.00153093109838665[0]1;32;1;1;0.0481324717402458;-0.0789960399270058;-0.0761178955435753;0.176791936159134;0.254073321819305;0.110900647938251;0.0450093746185303;0.016656531020999;0.262891501188278;-0.166014179587364;-0.292346626520157;0.293326407670975;-0.00306186219677329;0.288121223449707;-0.179547592997551;0.199939608573914;-0.247888371348381;-0.0411514267325401;-0.268770277500153;0.304839015007019;-0.0707902535796165;0.125352635979652;0.223699659109116;0.196449086070061;-0.064850240945816;0.0952239111065865;-0.137722566723824;0.22363843023777;-0.194918155670166;-0.0819966718554497;-0.0537050664424896;-0.255543023347855[0]1;32;1;1;0.286774039268494;-0.303124368190765;-0.191672578454018;-0.242377012968063;-0.267790466547012;0.0837725549936295;-0.139314740896225;0.186099991202354;-0.233620092272758;0.118922725319862;-0.0572568252682686;-0.00679733417928219;0.0128598213195801;-0.244826510548592;0.268096655607224;-0.107287652790546;0.275996267795563;-0.13857989013195;0.179670065641403;0.217453464865685;-0.0485611371695995;0.00232701539061964;-0.131292656064034;0.138334929943085;-0.101347640156746;-0.0451930873095989;-0.04164132848382;0.289652168750763;-0.0849360525608063;0.0528477430343628;0.128536984324455;-0.0107777556404471[0]1;32;1;1;-0.198898583650589;-0.107532605528831;-0.0503982529044151;-0.0103490939363837;-0.0881816297769547;-0.0210656132549047;-0.266933143138885;-0.195408046245575;0.304655313491821;0.0309860464185476;-0.0260258298367262;0.241335988044739;0.196755275130272;0.0553584732115269;-0.0503982529044151;-0.123270571231842;0.209370136260986;0.0486836098134518;-0.133864626288414;0.0879979208111763;0.233007714152336;-0.15094980597496;0.0758729428052902;-0.278323262929916;-0.0158604476600885;0.197551354765892;0.225046887993813;-0.170851930975914;0.292652785778046;0.103123523294926;0.122964389622211;-0.142131641507149[0]1;32;1;1;0.248561978340149;-0.161605104804039;-0.0131660085171461;-0.0901412293314934;0.188488245010376;0.0658912807703018;-0.291060626506805;-0.0515005253255367;-0.16558550298214;-0.00594001309946179;0.00734846945852041;-0.152358263731003;0.0327619276940823;0.0636867359280586;-0.100306607782841;0.0443970002233982;0.161911278963089;0.124189138412476;-0.20692066848278;0.259707152843475;-0.0361912101507187;0.131292656064034;0.0355788394808769;0.0278017111122608;0.00943053606897593;0.142376601696014;0.241580933332443;0.0298225395381451;0.0632580742239952;0.211697161197662;-0.0450706146657467;-0.293265163898468[0]1;32;1;1;0.272444516420364;-0.282977312803268;0.142621546983719;0.249051868915558;-0.147336810827255;0.0881204009056091;0.265830874443054;0.172750264406204;-0.271587193012238;-0.24727600812912;-0.0861608013510704;0.233987510204315;-0.181752145290375;0.272322028875351;0.0529089830815792;0.297490537166595;0.178690284490585;-0.0695042759180069;-0.290448248386383;-0.292469084262848;0.0656463280320168;0.176179558038712;-0.0186773594468832;0.00391918374225497;0.146418258547783;0.265769630670547;-0.135334312915802;-0.207533031702042;-0.222229957580566;0.301409721374512;-0.225781723856926;-0.0982245430350304[0]1;32;1;1;-0.211390972137451;-0.0501533038914204;-0.00140845670830458;-0.242805674672127;-0.0734846964478493;-0.12492398172617;-0.137845039367676;-0.264238715171814;-0.123760469257832;0.209308907389641;-0.157992079854012;-0.0766690373420715;0.0516229942440987;-0.271464705467224;-0.144397422671318;-0.0649727210402489;-0.259768396615982;0.161850035190582;-0.0516842342913151;-0.287692576646805;0.130251616239548;0.00936929881572723;-0.0352114178240299;0.138151228427887;-0.303859204053879;-0.247398480772972;-0.159094363451004;0.0175750888884068;0.188182055950165;0.074831910431385;-0.14500980079174;0.206002101302147[0]1;32;1;1;-0.0143907526507974;-0.0270668622106314;-0.279915452003479;0.102817334234715;0.102327436208725;-0.0453155636787415;-0.163380965590477;0.0488060861825943;-0.0909373089671135;-0.250337868928909;0.217943355441093;0.0505207292735577;0.207471802830696;-0.290999382734299;0.103490948677063;0.102817334234715;0.212003335356712;-0.085425965487957;0.200919404625893;0.18665112555027;0.256645292043686;-0.257380157709122;-0.144213706254959;0.00924682430922985;0.151011049747467;0.170117065310478;-0.0304961483925581;-0.068830668926239;-0.202144145965576;0.239437639713287;-0.0167790055274963;-0.220147892832756[0]1;32;1;1;0.262646555900574;0.0737908780574799;0.0560320802032948;-0.251195192337036;-0.0328844003379345;-0.283589690923691;0.121188506484032;-0.223026052117348;-0.187753394246101;-0.245438873767853;-0.0920395776629448;0.0761791318655014;-0.0387019366025925;0.0456217490136623;-0.120698608458042;0.119045205414295;-0.0544399097561836;-0.251072704792023;0.1303740888834;0.287325143814087;-0.174036264419556;0.186222463846207;-0.0451930873095989;0.124311603605747;0.295408487319946;-0.0431110225617886;-0.285120636224747;0.146846920251846;-0.239437639713287;0.0578079633414745;0.069565512239933;0.242560744285583[0]1;32;1;1;0.0667485967278481;0.166871502995491;-0.110533230006695;0.0765465572476387;0.227312654256821;-0.139682158827782;-0.146234542131424;-0.261666744947433;-0.0749543905258179;-0.29932764172554;-0.106981471180916;0.235824644565582;-0.198163717985153;-0.262156635522842;0.227435126900673;-0.0762403681874275;-0.210349932312965;-0.147949188947678;-0.016656531020999;0.252236217260361;-0.0486223734915257;-0.213044375181198;-0.231905445456505;0.081445537507534;-0.119841292500496;-0.0660749897360802;0.0437233932316303;0.215983763337135;0.206369519233704;-0.202878996729851;0.148928984999657;0.161298900842667[0]1;32;1;1;0.117575511336327;-0.206614464521408;-0.0879979208111763;-0.125536352396011;0.259462207555771;-0.0519291833043098;-0.172382861375809;-0.158114567399025;-0.283895879983902;0.222413688898087;0.206859409809113;-0.297184348106384;-0.193448454141617;0.0145132280886173;-0.132762357592583;0.0790572836995125;0.0285977944731712;0.0379058569669724;-0.022412832826376;0.175812125205994;-0.196265369653702;0.139682158827782;-0.155236423015594;-0.205634668469429;0.234967321157455;0.242805674672127;-0.249419301748276;-0.147336810827255;0.241397216916084;0.116963140666485;-0.231844216585159;-0.0502145439386368[0]1;32;1;1;-0.0421312265098095;-0.0413963757455349;0.174097493290901;0.236743181943893;-0.0528477430343628;0.239743813872337;0.04164132848382;-0.299940019845963;0.232701525092125;0.0501533038914204;-0.0640541538596153;0.262891501188278;0.25370591878891;0.0472139157354832;0.0917946323752403;-0.0681570544838905;-0.230252042412758;-0.252787351608276;0.302450746297836;0.00894063804298639;0.285549283027649;-0.136436581611633;-0.0600125007331371;0.10514435172081;-0.0184324104338884;-0.266443252563477;-0.25529807806015;0.158359512686729;-0.214820265769958;0.232027918100357;-0.176669463515282;0.0312922336161137[0]1;32;1;1;-0.209370136260986;0.0696879848837852;0.0851197689771652;0.277098536491394;0.293448895215988;-0.143295153975487;-0.299205183982849;-0.146663203835487;-0.185610085725784;0.296633213758469;0.281262665987015;0.190080419182777;-0.214636534452438;0.0124311614781618;-0.13086399435997;0.0633193105459213;0.00545011460781097;-0.115309730172157;-0.106430336833;0.171341806650162;-0.255175620317459;0.113227665424347;0.239253923296928;-0.278200805187225;-0.0671160221099854;0.250950217247009;-0.0119412634521723;-0.0522966086864471;0.182854413986206;-0.25064405798912;0.110165812075138;0.226455330848694[0]1;32;1;1;-0.133497193455696;-0.226822763681412;0.2504603266716;0.190447822213173;-0.253277242183685;-0.156338676810265;0.277588427066803;-0.0666873604059219;0.216534897685051;0.170668199658394;0.271954596042633;-0.241825878620148;-0.305818796157837;-0.133619666099548;0.128843158483505;-0.160502821207047;-0.0611760094761848;-0.242805674672127;0.107532605528831;-0.285549283027649;0.0983470231294632;0.292407840490341;0.134109571576118;0.117942936718464;0.031108520925045;-0.101408876478672;0.107655078172684;0.0350889414548874;-0.0812618210911751;-0.106981471180916;-0.0635642632842064;-0.2470922768116[0]1;32;1;1;-0.128047078847885;0.179608836770058;0.0221678838133812;0.0280466582626104;-0.287998765707016;0.106675282120705;0.000918558682315052;-0.112676531076431;-0.125536352396011;0.0387631766498089;-0.173178926110268;0.0159829221665859;0.248806938529015;-0.0424374118447304;0.0876917317509651;-0.139253497123718;0.0454992726445198;0.135456785559654;-0.17734307050705;-0.00428660726174712;0.0959587618708611;-0.109063535928726;0.0589102283120155;0.0208819005638361;-0.0398042090237141;-0.225046887993813;0.00802207924425602;0.17299522459507;0.127373471856117;-0.170055836439133;-0.0410901941359043;0.287386387586594[0]1;32;1;1;0.153276816010475;0.189039379358292;-0.051867950707674;-0.302205801010132;0.264238715171814;0.0254746936261654;-0.0202082917094231;-0.0216779839247465;0.0267606750130653;0.200429514050484;-0.245377644896507;-0.274465322494507;0.0818129554390907;-0.197857543826103;-0.300674885511398;0.124495320022106;0.23649825155735;0.192407429218292;-0.274220407009125;-0.220392853021622;0.219290569424629;-0.29050949215889;0.266137063503265;-0.301654666662216;-0.242009609937668;0.299205183982849;-0.128720685839653;0.276241213083267;-0.305022716522217;-0.268402844667435;-0.265892118215561;-0.157930850982666[0]1;32;1;1;-0.119841292500496;0.165646746754646;-0.0646052956581116;0.18873319029808;0.148377850651741;0.290754437446594;-0.0834663659334183;0.172811508178711;-0.183221831917763;0.275873810052872;-0.083098940551281;0.261115610599518;-0.136191636323929;-0.0789960399270058;0.26638200879097;0.0255971681326628;-0.141458034515381;-0.0475813373923302;-0.137600094079971;0.13649782538414;0.232272878289223;0.022412832826376;0.214391604065895;-0.265953361988068;-0.183528020977974;-0.0135946683585644;0.156828582286835;-0.18971298635006;0.158053338527679;0.161911278963089;0.16766756772995;0.11286024749279[0]1;32;1;1;0.107103936374187;0.100367844104767;-0.137906283140182;-0.103123523294926;-0.158665701746941;-0.157930850982666;-0.0558483675122261;0.140600711107254;-0.0334355346858501;-0.181690901517868;-0.159767970442772;0.0975509285926819;-0.146050825715065;0.00238825241103768;0.154134154319763;0.193019792437553;0.143111452460289;0.291611760854721;0.24966424703598;0.156032502651215;-0.206247046589851;-0.0344153344631195;-0.207471802830696;-0.19742888212204;0.26913771033287;-0.265953361988068;-0.235395982861519;0.240111246705055;0.192223712801933;0.23986628651619;-0.159951686859131;-0.256645292043686!0]1;32;1;1;0.1383246332407;0.3110171854496;0.264965862035751;0.190260320901871;-0.397406131029129;0.215503290295601;0.0192733462899923;-0.184887662529945;-0.396894454956055;0.2103011906147;-0.0821249186992645;-0.404313832521439;-0.139262706041336;0.176956593990326;0.420175969600677;0.0566261112689972;-0.111290775239468;-0.173204258084297;0.366790503263474;0.0128773236647248;0.409771800041199;-0.020126149058342;-0.0939788818359375;-0.147279053926468;-0.325088441371918;-0.333787053823471;-0.405251920223236;0.183267340064049;-0.141053587198257;0.124338656663895;-0.131246358156204;-0.228124782443047

And this is the log: autosave.csv https://pastebin.com/kYeUWHRH

Kryuski commented 2 years ago

I have found out that the same "bad" NN breaks Lazarus compiled program as well. Only need to disable validation during training for this to work with Lazarus: NFit.Fit(NN, TrainingPairs, nil{ValidationPairs}, TestPairs, {batchsize=}32, {epochs=}50);

I tested this NN on two AMD Ryzen 5 3600 computers with the same result:

Inputs:19.00, 71.00 - Output: 0.00  Desired Output:73.50
Inputs:28.00,  6.00 - Output: 0.00  Desired Output:28.64
Inputs:34.00, 53.00 - Output: 0.00  Desired Output:62.97
Inputs:20.00, 35.00 - Output: 0.00  Desired Output:40.31
Inputs:53.00, 28.00 - Output: 0.00  Desired Output:59.94
Inputs:56.00, 12.00 - Output: 0.00  Desired Output:57.27
Inputs:77.00, 29.00 - Output: 0.00  Desired Output:82.28
Inputs:69.00, 31.00 - Output: 0.00  Desired Output:75.64
Inputs:24.00, 78.00 - Output: 0.00  Desired Output:81.61
Inputs:15.00, 22.00 - Output: 0.00  Desired Output:26.63

Now I think this is not related to Delphi, but to the processor. Because sometimes after processing the "bad" NN, subsequent tests of random NN also result in the same error. It would be nice to check the "bad" NN on Intel processors.

Kryuski commented 2 years ago

After further research, I think this has nothing to do with a compiler or a processor. This is a problem of the chosen type of layers (TNNetFullConnectReLU) and the activation function (FData > 0). Its result reaches the boundary values, and cannot get out of the local minimum.

joaopauloschuler commented 2 years ago

@Kryuski, many thanks for your detailed bug reports. I agree with your diagnostic. I'll fix these examples and their readme files in the next few days. You've been able to convince me to add randomize by default.

Kryuski commented 2 years ago

Well, if the NN trains well and shows the correct results, and only in corner cases does not converge, this is a good result. I think this issue can be closed.

joaopauloschuler commented 2 years ago

Is the "need to disable validation during training for this to work with Lazarus" still broken for you?