aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2021-03-16 22:19:17 -0400
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit93387bf4b0cf54f8a84b13d4ad4751e7ef81a788 (patch)
treefff5eddcd1fb11c65c611977de2aba7bab27a9c3
parent00a04c2929bdc8f8f4bf7d5d8cf413ebfb3cd006 (diff)
Snapshot: AMMEND ME
-rw-r--r--Makefile9
-rw-r--r--include/cnn1986.c11
-rw-r--r--include/cnn1986.h5
-rw-r--r--include/weights.c16
-rw-r--r--include/weights.h22
-rw-r--r--src/ctnn.c336
6 files changed, 378 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 8b4ab58..0dbaec7 100644
--- a/Makefile
+++ b/Makefile
@@ -22,14 +22,15 @@ ctlm: src/ctlm.o $(OBJS)
cttei: src/cttei.o $(OBJS)
$(CC) $(CFLAGS) src/cttei.o $(OBJS) -o cttei
-pptdb: src/pptdb.o $(CTAK_OBJS)
- $(CC) $(CFLAGS) src/pptdb.o $(CTAK_OBJS) -o pptdb
+ctnn: CFLAGS=$(CFLAGS) -lm
+ctnn: src/ctnn.o $(OBJS)
+ $(CC) $(CFLAGS) src/ctnn.o $(OBJS) -o ctnn
clean:
- rm -f ctlm ct1986 cttei pptdb
+ rm -f ctlm ct1986 cttei ctnn
rm -f src/*.o include/*.o
-native: clean ctlm cttei
+native: clean ctlm cttei ctnn
$(CROSS_CC):
./resources/do_buildroot.sh $(BUILDROOT_DIR)
diff --git a/include/cnn1986.c b/include/cnn1986.c
index dc0e116..10f4e4c 100644
--- a/include/cnn1986.c
+++ b/include/cnn1986.c
@@ -16,7 +16,6 @@
*/
#include "cnn1986.h"
-#include "weights.h"
// ===================================================================
// Implementation of a small convolutional neural network
@@ -110,3 +109,13 @@ float cnn1986_evaluate_black_win(void) {
}
return output;
}
+
+// ===================================================================
+// Compute grad(cnn1986) with respect to the weights and biases
+// ===================================================================
+
+float cnn1986_gradient[NUM_PARAMETERS];
+
+void cnn1986_compute_gradient(void) {
+
+}
diff --git a/include/cnn1986.h b/include/cnn1986.h
index 97f84d9..c9fd376 100644
--- a/include/cnn1986.h
+++ b/include/cnn1986.h
@@ -16,5 +16,10 @@
*/
#include <tak.h>
+#include <weights.h>
+
+extern float cnn1986_gradient[NUM_PARAMETERS];
float cnn1986_evaluate_black_win(void);
+
+void cnn1986_compute_gradient(void);
diff --git a/include/weights.c b/include/weights.c
index ec28401..1c692db 100644
--- a/include/weights.c
+++ b/include/weights.c
@@ -17,26 +17,26 @@
#include "weights.h"
-const float conv2d_weights[KERN_NUM][KERN_SIZE][KERN_SIZE][KERN_CHAN] =
+float conv2d_weights[KERN_NUM][KERN_SIZE][KERN_SIZE][KERN_CHAN] =
{{{{0.36853331327438354, 0.13197043538093567, -0.10850891470909119, 0.11439184099435806, -0.18103714287281036, 0.2870127856731415}, {0.22437581419944763, 0.22473859786987305, -0.07241908460855484, -0.18087545037269592, -0.4224194288253784, 0.08597474545240402}, {0.2862361669540405, 0.045642510056495667, 0.20831039547920227, 0.1295289546251297, 0.6973511576652527, -0.024992210790514946}}, {{0.23791751265525818, 0.12410031259059906, -0.01995648629963398, -0.027202459052205086, -0.08278238028287888, -0.160722017288208}, {0.7002286314964294, 0.26837587356567383, 0.2776748836040497, 0.5116508603096008, -0.20092159509658813, -0.07630595564842224}, {0.459989994764328, 0.11799280345439911, 0.13892707228660583, 1.010933756828308, 0.2575095593929291, -0.700024425983429}}, {{1.043813705444336, 0.2491917759180069, -0.1860327422618866, -0.11774677783250809, 0.3819361925125122, 0.017854824662208557}, {1.4321590662002563, -0.034674979746341705, 0.033052533864974976, 0.4322509169578552, 0.8070812225341797, 0.9787366390228271}, {2.148289680480957, 0.2654041647911072, 0.4971856474876404, 1.0566805601119995, 1.1781615018844604, 1.9458420276641846}}}, {{{2.8043012619018555, 0.5981557369232178, 0.14076505601406097, 0.44255906343460083, -0.2780279517173767, 0.31853681802749634}, {0.4342345595359802, -0.04190421476960182, 0.4480525255203247, 0.9858571290969849, -0.4627513587474823, 0.40116599202156067}, {-0.9317502379417419, 0.07250810414552689, -0.18414995074272156, -0.3566206991672516, -0.2459440678358078, -0.05446876585483551}}, {{0.5030801296234131, 0.13176029920578003, -0.033242058008909225, 0.06673198193311691, 0.374639093875885, 0.4195535480976105}, {-0.4617132246494293, 0.14843060076236725, -0.12188810855150223, -0.3877445161342621, -0.0800260379910469, -0.8219804167747498}, {-0.5283677577972412, -0.12185059487819672, 0.06713918596506119, 0.2718829810619354, 0.173270121216774, -0.6711069941520691}}, {{0.08322977274656296, -0.18435949087142944, -0.013488933444023132, -0.38123974204063416, 0.7090172171592712, -0.8116384744644165}, {-0.16320005059242249, 0.2736445367336273, -0.1458773910999298, -0.3400840759277344, 0.2123827040195465, -1.0862748622894287}, {-0.14335627853870392, 0.05336679518222809, 0.00552770309150219, 0.05464665964245796, -0.23052190244197845, -0.4520905613899231}}}, {{{0.3625907003879547, -0.25347957015037537, 0.24311427772045135, 0.4751688241958618, 0.5261889696121216, 0.5765055418014526}, {1.1278742551803589, 0.2368684709072113, 0.1968187391757965, 0.1820613443851471, 0.2607775330543518, 0.07630332559347153}, {-0.07774196565151215, -0.031166110187768936, -0.07550635933876038, 0.44522079825401306, 0.1973133683204651, 0.32190650701522827}}, {{1.0389032363891602, 0.13338688015937805, 0.18729910254478455, 0.17540185153484344, 0.04116402193903923, -0.33788323402404785}, {0.17360253632068634, 0.12091411650180817, 0.0842951089143753, 0.1802147924900055, 0.07530909776687622, 0.3635297417640686}, {0.7771968841552734, 0.23097647726535797, 0.17835092544555664, -0.17011681199073792, 0.2115011215209961, 0.28798195719718933}}, {{0.6192851662635803, 0.022625546902418137, 0.21817998588085175, 0.22533614933490753, 0.025148002430796623, 0.5501201748847961}, {0.8939119577407837, 0.03640613332390785, 0.05934160575270653, 0.15625111758708954, -0.021111484616994858, 0.21483953297138214}, {-0.06323949992656708, -0.2032194882631302, -0.13115160167217255, -0.017766162753105164, -0.10735264420509338, -0.30792075395584106}}}, {{{-0.12249187380075455, -0.18435627222061157, -0.03533153608441353, -0.24531541764736176, -0.026564089581370354, -0.42447829246520996}, {-0.14097285270690918, -0.18730753660202026, -0.1958683580160141, 0.047689784318208694, 0.08839572221040726, -0.10003238916397095}, {-0.45746928453445435, -0.2567964196205139, -0.31645768880844116, -0.38906657695770264, -0.16522565484046936, -0.07838720828294754}}, {{-0.011095648631453514, 0.2970455586910248, 0.2504645586013794, 0.16319099068641663, 0.12874269485473633, 0.18941813707351685}, {-0.06969325244426727, -0.10338503867387772, 0.005549769848585129, 0.22490398585796356, -0.061957888305187225, 0.22812047600746155}, {-1.0291906595230103, -0.3009341061115265, -0.14633411169052124, -0.45392656326293945, -0.51871657371521, -0.862667441368103}}, {{0.1917204111814499, -0.0510188490152359, 0.007119815796613693, 0.7228220105171204, 0.29497233033180237, 0.32933491468429565}, {0.40079012513160706, 0.23186279833316803, 0.11672820150852203, 0.07689567655324936, -0.06533240526914597, -0.3635445237159729}, {-1.913336157798767, -0.48580050468444824, -0.08847742527723312, -0.3362463712692261, -0.10492833703756332, -0.7262025475502014}}}, {{{-0.061563413590192795, 0.0845799595117569, 0.005723972339183092, 0.18494603037834167, 0.43687769770622253, 0.26093801856040955}, {-0.6335328817367554, -0.16688567399978638, -0.11816214770078659, -0.07295821607112885, -0.2829402983188629, -0.10576433688402176}, {-1.016042947769165, -0.021593062207102776, -0.10920312255620956, -0.3226301670074463, -0.0330846831202507, 0.04788395017385483}}, {{-0.07654525339603424, 0.14090591669082642, 0.14645099639892578, 0.17799167335033417, -0.07417642325162888, 0.1496438831090927}, {-0.48197346925735474, -0.1388481855392456, 0.031081423163414, -0.0755804032087326, -0.26870837807655334, 0.22645631432533264}, {1.7206103801727295, -0.218328058719635, -0.12412701547145844, 0.06527724862098694, 0.10605369508266449, 0.10580744594335556}}, {{-0.1568414717912674, -0.1902957558631897, 0.12730790674686432, 0.0574195496737957, -0.4043963551521301, -0.0073846448212862015}, {0.2705155313014984, 0.16274090111255646, -0.03367019072175026, -0.035613153129816055, 0.0808665007352829, 0.5641733407974243}, {0.4084755480289459, -0.0013839717721566558, 0.07734677940607071, 0.07815942913293839, 0.35568758845329285, 0.3561573624610901}}}, {{{1.1070384979248047, -0.23465721309185028, 0.3139123022556305, 0.4914771616458893, 1.2322015762329102, 0.6010463833808899}, {0.7837856411933899, -0.2002493441104889, -0.06414883583784103, -0.006303523667156696, 0.3729422986507416, 0.0214411448687315}, {0.6771957278251648, 0.04044964164495468, 0.010175158269703388, -0.030905166640877724, -0.08313947170972824, 0.02828463539481163}}, {{0.3588506877422333, 0.3021303117275238, 0.19490420818328857, 0.41656604409217834, 0.4883577823638916, 0.20982570946216583}, {0.38774895668029785, -0.017752137035131454, 0.2741468548774719, 0.5110231041908264, 0.14892414212226868, 0.029608706012368202}, {0.029468892142176628, 0.013304182328283787, -0.040127046406269073, 0.2554202973842621, 0.018175194039940834, 0.008323008194565773}}, {{-1.2786340713500977, -0.30686241388320923, 0.1794748455286026, -0.12508292496204376, 0.07393521815538406, 0.17330414056777954}, {-0.7309134602546692, -0.08941660821437836, 0.11421722173690796, -0.016809377819299698, -0.3343416154384613, -0.3121510148048401}, {-0.6887509226799011, -0.04171470180153847, -0.2381068766117096, -0.31102702021598816, 0.13327881693840027, 0.048931438475847244}}}, {{{-1.4889484643936157, -0.5068660974502563, 0.022097894921898842, 0.29979559779167175, -0.01564616896212101, -0.17528942227363586}, {-0.9739673733711243, -0.011822246015071869, 0.01819584146142006, -0.3880571126937866, -0.2768211364746094, 0.10872015357017517}, {-0.5329640507698059, -0.14220786094665527, 0.0032796834129840136, -0.25490280985832214, -0.18998588621616364, 0.023495879024267197}}, {{1.2054252624511719, 0.09268004447221756, -0.0435849204659462, 0.2405174821615219, 0.041635964065790176, 0.04074803739786148}, {-0.18779927492141724, -0.11105775088071823, -0.24978162348270416, -0.2650945484638214, -0.05307250842452049, -0.025725288316607475}, {-0.18719260394573212, 0.023694215342402458, -0.10807090252637863, -0.33897683024406433, 0.10573288053274155, 0.4209464490413666}}, {{0.5351808667182922, -0.21604514122009277, 0.3921806812286377, 0.2933255732059479, 0.2865733504295349, 0.37946370244026184}, {0.151222825050354, 0.15313123166561127, 0.06454786658287048, 0.12839758396148682, -0.3617597818374634, -0.010003617964684963}, {0.07248389720916748, 0.1574150174856186, 0.14141133427619934, 0.11110616475343704, -0.08698829263448715, -0.43668270111083984}}}, {{{-0.6809251308441162, -0.2796165347099304, 0.15937145054340363, -0.1953924149274826, -0.07890231907367706, -0.12184988707304001}, {-0.3568345010280609, -0.0978836715221405, -0.10756655782461166, -0.18537785112857819, -0.05635782331228256, -0.32790133357048035}, {-0.4806964099407196, -0.0817788615822792, -0.08815523982048035, -0.15721312165260315, -0.5297232866287231, 0.31730926036834717}}, {{-0.5918986201286316, -0.06029416248202324, -0.042137425392866135, -0.21137964725494385, -0.40359190106391907, -0.61113440990448}, {-1.1760245561599731, -0.43901675939559937, -0.25475332140922546, -0.1870921105146408, -0.08888094872236252, -0.1631394922733307}, {-0.5192657709121704, 0.08683575689792633, -0.1590515673160553, -0.49972954392433167, -0.33534538745880127, -0.3354673981666565}}, {{-1.2496943473815918, -0.383198082447052, -0.13794279098510742, -0.2713302671909332, -0.44351115822792053, -0.25412723422050476}, {-0.9482824802398682, -0.07494381815195084, -0.11454141139984131, -0.17054466903209686, -0.4977518320083618, -0.20517124235630035}, {-1.6152344942092896, -0.2861875891685486, -0.3131437599658966, -0.6476004719734192, -0.3282027840614319, -0.7949329018592834}}}, {{{-0.09832935780286789, -0.04834149777889252, -0.015423079952597618, -0.49241510033607483, -0.2619456946849823, 0.5459940433502197}, {-0.6712737083435059, -0.12882614135742188, -0.11400792002677917, -0.17141227424144745, -0.3869696259498596, -0.07293424010276794}, {1.864503026008606, 0.09406209737062454, 0.017940543591976166, 0.08570969849824905, 0.027632206678390503, -0.2393411546945572}}, {{0.09261734038591385, -0.019253108650445938, 0.05569816380739212, -0.06565923243761063, 0.08916200697422028, -0.04948277026414871}, {-0.7281373739242554, -0.09446638822555542, -0.30272549390792847, -0.21851171553134918, -0.16249355673789978, -1.6341273784637451}, {-0.6238022446632385, 0.05107368528842926, 0.04151986539363861, 0.12253237515687943, 0.04475610703229904, 0.21880662441253662}}, {{0.2697039544582367, -0.0380067303776741, 0.0591510646045208, 0.2476884424686432, 0.05840697139501572, 0.020185058936476707}, {0.0535871796309948, -0.08285997062921524, -0.10817840695381165, 0.24669615924358368, -0.17751045525074005, 0.2014371156692505}, {-0.10232175141572952, 0.03574812784790993, -0.10773446410894394, -0.10092856734991074, 0.38399121165275574, 0.263602614402771}}}, {{{-0.7296270132064819, -0.18232731521129608, -0.2804740369319916, -0.13047927618026733, -0.04522360488772392, 0.08713225275278091}, {-0.532118558883667, 0.02019045315682888, -0.27713465690612793, -0.2730518579483032, -0.23757903277873993, -0.06476064026355743}, {0.4238220155239105, 0.03758782148361206, -0.31548044085502625, 0.03886980935931206, 0.018184691667556763, 0.5070154070854187}}, {{-0.5453790426254272, -0.03513007611036301, -0.18239326775074005, -0.0082879438996315, -0.05401647090911865, -0.3523097038269043}, {-1.143595576286316, -0.32067155838012695, -0.11242102086544037, -0.16515007615089417, -0.21676310896873474, -0.11863797903060913}, {0.527651309967041, 0.0047509316354990005, -0.3207671344280243, -0.2672143280506134, -0.1511600911617279, -0.27125927805900574}}, {{0.25613754987716675, -0.1538715362548828, -0.06482989341020584, -0.1414237767457962, -0.11217597872018814, 0.07572130858898163}, {0.45554834604263306, -0.08136619627475739, -0.4179629385471344, -0.2428581565618515, -0.0716448724269867, -0.1987352818250656}, {1.2172012329101562, 0.18101322650909424, -0.04411967471241951, 0.4677446782588959, 1.332121729850769, 0.99836266040802}}}, {{{0.1125025525689125, -0.1240389421582222, -0.26808416843414307, 0.2893787920475006, 0.1314091980457306, -0.40878766775131226}, {0.3061106204986572, 0.21415075659751892, -0.10973993688821793, -0.08399570733308792, 0.041290510445833206, 0.15590684115886688}, {2.451629400253296, 0.10974716395139694, 0.3302524983882904, 0.9166426062583923, 0.9505067467689514, 3.0855789184570312}}, {{-0.17526677250862122, 0.03014497086405754, -0.016387982293963432, 0.023046938702464104, 0.15390880405902863, -0.19801568984985352}, {-0.4321306347846985, 0.10731697827577591, 0.05044100806117058, -0.002793865744024515, 0.20044197142124176, -0.0032333722338080406}, {0.7185532450675964, 0.21092058718204498, -0.25161534547805786, -0.2519127428531647, -0.26742199063301086, -0.14072707295417786}}, {{-0.08288266509771347, -0.06264658272266388, -0.06707384437322617, -0.11615598201751709, 0.18672841787338257, 0.4857807457447052}, {-0.0868537500500679, 0.13319343328475952, -0.015241078101098537, 0.0886245146393776, 0.21114961802959442, -0.20952124893665314}, {0.34127458930015564, 0.02762525901198387, 0.21963180601596832, 0.1038631722331047, 0.1283234804868698, -0.19774582982063293}}}, {{{-0.00014440453378483653, 0.028640659525990486, -0.04061955213546753, 0.007745813578367233, 0.08791922777891159, 0.1307181864976883}, {0.6153806447982788, -0.018886251375079155, 0.060682374984025955, 0.13116104900836945, -0.06874489784240723, -0.4435003995895386}, {-2.315500259399414, -0.25503769516944885, -0.08943793177604675, -0.34831860661506653, -0.2889763414859772, -0.4910445809364319}}, {{0.10100555419921875, 0.0658496767282486, 0.027597684413194656, 0.20125119388103485, -0.018323184922337532, -0.1000547930598259}, {0.6646155714988708, 0.10891660302877426, 0.13397027552127838, 0.21550534665584564, -0.4845636188983917, 0.900590181350708}, {0.8783279657363892, -0.11221140623092651, 0.06741434335708618, -0.0022904137149453163, 0.2159164696931839, -0.0882004052400589}}, {{-0.15003599226474762, -0.004615450277924538, 0.019562946632504463, -0.26560842990875244, -0.18717321753501892, -0.22792169451713562}, {0.036111194640398026, 0.05467988923192024, -0.10909625142812729, -0.1584160178899765, 0.0924181118607521, -0.03339894488453865}, {0.01650945656001568, 0.01122982520610094, -0.043706752359867096, 0.018709754571318626, -0.0032730891834944487, 0.03754238411784172}}}};
-const float conv2d_biases[KERN_NUM] =
+float conv2d_biases[KERN_NUM] =
{-0.6451589465141296, -0.47988107800483704, 1.0866423845291138, 0.8259075880050659, 0.7077365517616272, 0.06997911632061005, 0.7337013483047485, 0.7401207685470581, 0.3617548644542694, 0.9209133386611938, -0.8768176436424255, 0.4427519142627716};
-const float dense1_weights[DENSE1_NUM][CONV_NUM+2] =
+float dense1_weights[DENSE1_NUM][CONV_NUM+2] =
{{1.0535576343536377, -0.13765782117843628, 0.4458506405353546, 0.017704816535115242, 0.16654333472251892, 1.988281011581421, 1.423511266708374, -1.076285719871521, 0.31845995783805847, -1.2419943809509277, 0.5747542977333069, -0.5936117172241211, 0.6230117678642273, -0.41226616501808167, 0.23031051456928253, 0.6637664437294006, 0.04129592329263687, -0.10971066355705261, 0.6160904765129089, -0.7729862928390503, 0.4112888276576996, -0.32791024446487427, 0.6544229388237, -0.21252456307411194, -0.8629195690155029, 0.07906495034694672, -0.32754015922546387, -0.36489248275756836, -0.09536723792552948, 0.2869880497455597, 0.27527952194213867, -0.6454789042472839, -0.3707139492034912, -0.09653671085834503, 1.3492153882980347, -0.11703509837388992, -0.4595806896686554, -0.006820190232247114, -0.9968237280845642, 0.5343625545501709, 0.43985480070114136, -0.32416728138923645, 1.7352285385131836, -0.7003371119499207, 0.8714061975479126, -1.2230373620986938, 0.14532382786273956, -0.4315739870071411, 0.6903901696205139, -0.02914654277265072, 0.14594882726669312, -0.0438900925219059, 0.0660790428519249, 0.09821983426809311, 0.49424201250076294, -0.8857726454734802, 0.627997875213623, -0.5567572712898254, 0.9108500480651855, -0.4091767370700836, -0.2832707464694977, 0.13177846372127533, -0.10077259689569473, 0.05184166878461838, -0.10469815880060196, -0.08393889665603638, 0.5399074554443359, -1.1768603324890137, 0.62517249584198, -0.5544601678848267, 1.8188426494598389, 0.07897178083658218, -1.1368229389190674, -0.4065854549407959, -1.4979749917984009, 0.6648167371749878, 1.1669824123382568, -0.07228367030620575, 0.15067777037620544, 1.6310100555419922, 0.6072654724121094, -0.381766140460968, 0.9733656644821167, -0.5240350365638733, 0.082554392516613, -0.1991836577653885, 0.1622454971075058, 2.1914143562316895, 0.3106246590614319, -0.7196137309074402, -0.012188534252345562, -1.0873465538024902, 0.8631598949432373, -0.04625372961163521, 1.3172123432159424, -0.6265043616294861, -0.35009968280792236, -0.050299957394599915, 0.028834126889705658, 1.6971173286437988, 0.30326971411705017, -1.1694163084030151, 0.8350977301597595, -1.601547122001648, 0.32297876477241516, -0.20485509932041168, 1.9583266973495483, -0.06550899893045425, -0.08437135815620422, 1.564854621887207}, {-0.1706523299217224, 0.6225836873054504, -0.15462496876716614, -0.46067893505096436, 1.3940848112106323, -0.23391196131706238, -1.9550093412399292, 0.7329625487327576, 0.5619151592254639, 0.7686570286750793, 0.43044453859329224, -0.5238238573074341, -0.7907667756080627, 1.1216131448745728, 0.4314754009246826, 0.21430647373199463, -0.27971914410591125, -0.3280380666255951, 0.19799736142158508, 0.3083905279636383, -0.8750405311584473, 1.2117339372634888, 0.609067440032959, 1.044189214706421, 0.8276583552360535, -2.062088966369629, 0.26722052693367004, 0.046504925936460495, -0.5067272782325745, 0.2874516546726227, -1.2008882761001587, -0.5225978493690491, -0.30236905813217163, 0.399198055267334, -2.0131640434265137, -1.0219560861587524, -0.2668384909629822, 0.4892066717147827, -0.8749388456344604, -0.02728516235947609, -0.08756641298532486, 0.021872999146580696, -1.313302993774414, 0.3333043158054352, -0.0814959704875946, -0.6686313152313232, -0.16623112559318542, 0.08324819803237915, -0.29121798276901245, 0.41688963770866394, -0.8008449673652649, 0.3132440149784088, -0.30437198281288147, 0.30163079500198364, -0.667481541633606, 0.41586369276046753, -0.7589012384414673, -0.08392846584320068, -0.05151311680674553, 1.2757503986358643, 0.4592227637767792, -0.15721310675144196, -0.27007514238357544, 0.08399961143732071, -0.24409492313861847, 0.5038453340530396, 0.008093279786407948, -0.8583636283874512, 0.0986485406756401, 0.6343539357185364, -0.6426138281822205, 0.42916339635849, 0.022625161334872246, 1.1464487314224243, -1.0418760776519775, -0.7476118206977844, 0.1767522543668747, 0.8543083071708679, 0.8471230268478394, 0.3503739833831787, -0.6314967274665833, -0.1659364551305771, -0.6145069003105164, 0.755817174911499, 0.8994852900505066, 0.11746779084205627, 0.5623553395271301, -0.8218250274658203, -0.38252514600753784, -0.4470851421356201, 0.5193712115287781, 0.3430037200450897, -0.5063608288764954, -0.1907166838645935, -0.9974657893180847, 0.6364694237709045, 0.03585687279701233, 0.33494600653648376, -0.7108443379402161, -0.8022319674491882, -1.4323893785476685, 0.6401885151863098, 0.23427435755729675, 1.323670744895935, -0.527867317199707, 0.49640774726867676, -1.5311496257781982, 0.6497474908828735, 4.618725776672363, 0.45700591802597046}, {-0.03803888335824013, -3.082787275314331, 0.43230777978897095, 0.26298174262046814, 0.30395784974098206, -0.008863388560712337, -0.5638167262077332, -0.14943894743919373, 0.04485673829913139, -1.2146286964416504, 2.3921566009521484, -0.3797832131385803, 0.6400709748268127, 1.3811886310577393, 0.5721665024757385, -0.7270181775093079, -0.4376876652240753, -0.337883859872818, -1.0121980905532837, -0.30063596367836, 0.6597622632980347, 0.0956902876496315, 1.6425988674163818, -1.8377100229263306, 1.496179461479187, -1.5299935340881348, -0.648257315158844, 0.13532105088233948, 0.1432720124721527, -1.027123212814331, 0.5438602566719055, -0.007809825707226992, -0.6217471957206726, 0.12882104516029358, -3.501546859741211, -0.22223445773124695, 1.0012495517730713, -1.0452978610992432, 0.23014222085475922, -0.1406600922346115, 0.014686482027173042, 0.39247965812683105, -0.5597139000892639, -0.2905016541481018, 0.18556328117847443, -0.5401838421821594, 1.8101228475570679, -0.6486750245094299, 0.2906841039657593, 0.8778757452964783, 0.4683176577091217, -0.5668071508407593, 0.26286041736602783, -0.22475947439670563, 0.8364123106002808, 0.711344838142395, 0.5704973340034485, -0.5068278908729553, 0.3731580972671509, -0.35223689675331116, 1.1446870565414429, -0.45814576745033264, 1.3770023584365845, -0.1903156340122223, -0.35087764263153076, -0.2535507380962372, -0.2466997653245926, -0.08121880888938904, 0.29350292682647705, -0.419569730758667, -3.258526086807251, -0.6745727062225342, 0.8636196851730347, 0.6637692451477051, 0.12311577051877975, 0.42304855585098267, 0.2706524729728699, 2.022864580154419, 0.6355319023132324, -0.8261646032333374, 0.9167037010192871, -0.16788923740386963, 0.23269198834896088, -0.5102846622467041, 0.7215372920036316, 0.4496469795703888, -0.13857345283031464, 0.28405922651290894, 1.0072591304779053, -0.9856377243995667, 1.3233997821807861, -1.7867225408554077, 0.43060046434402466, -0.5130675435066223, -0.13282640278339386, -0.5420711040496826, 0.9595379829406738, -0.16248342394828796, 0.25016140937805176, -0.5284724831581116, 1.0759111642837524, 0.7794250845909119, -0.13020597398281097, -0.2913711369037628, 1.386738657951355, -1.3039318323135376, 0.29373136162757874, -0.24355806410312653, 0.6589671969413757, 2.1357903480529785}, {-0.08341452479362488, -0.06519053876399994, -0.22915227711200714, 0.029149794951081276, 0.1450643390417099, -0.07372588664293289, 0.16437800228595734, -0.3172092139720917, -0.11067210137844086, -0.029404133558273315, -0.1505616456270218, 0.011282180435955524, 0.05099628493189812, 0.09221924096345901, -0.25054630637168884, -0.130552738904953, -0.15454337000846863, 0.037674952298402786, -0.23879915475845337, -0.02413356490433216, 0.11104713380336761, -0.0021996579598635435, -0.08874867856502533, -0.1947178691625595, -0.16904306411743164, -0.21769177913665771, 0.09211988747119904, -0.043976061046123505, -0.11341025680303574, -0.09137529879808426, -0.21908162534236908, -0.20268671214580536, 0.1495959311723709, -0.021787423640489578, -0.09432531893253326, -0.18214602768421173, -0.010079418309032917, -0.2277492880821228, -0.2247263789176941, 0.13202694058418274, -0.1975923478603363, 0.03717706352472305, -0.20996622741222382, -0.19070665538311005, 0.04736999049782753, -0.012295384891331196, -0.13108684122562408, -0.024530211463570595, 0.12262311577796936, -0.018957797437906265, -0.05852922797203064, -0.22016888856887817, -0.15779505670070648, 0.044586583971977234, -0.19915637373924255, -0.02207992412149906, 0.148987278342247, -0.06561733037233353, 0.023116689175367355, -0.13684667646884918, 0.06453219056129456, -0.05268482863903046, -0.17155654728412628, -0.03386813402175903, -0.17755788564682007, -0.13395783305168152, 0.1246139258146286, 0.05126357823610306, 0.05398029461503029, -0.15567854046821594, -0.2325979620218277, -0.1931237280368805, 0.09357582777738571, 0.04117527976632118, -0.2983706593513489, 0.05402951315045357, 0.10908876359462738, 0.16730572283267975, -0.005136633291840553, -0.15184347331523895, -0.09197723865509033, -0.12960517406463623, -0.1930316686630249, -0.047287363559007645, -0.14453217387199402, -0.16111665964126587, -0.08192909508943558, 0.03401917219161987, -0.08760187774896622, -0.08030490577220917, 0.13206438720226288, -0.21239154040813446, -0.12600208818912506, -0.07345689833164215, -0.22708289325237274, 0.14409670233726501, -0.23773692548274994, -0.004578204359859228, 0.17009223997592926, 0.036602314561605453, -0.055549491196870804, -0.03999188542366028, -0.06166914105415344, -0.17663855850696564, -0.23513346910476685, -0.28474944829940796, -0.14581453800201416, -0.007190295960754156, -0.00542578287422657, -0.20127342641353607}, {-0.15848882496356964, -0.05838637426495552, -0.7610356211662292, -0.20468273758888245, -0.175126850605011, -0.19755326211452484, 0.3738928735256195, 0.45670175552368164, -0.5014824867248535, 0.5577192902565002, -0.13207092881202698, 0.5261358618736267, 0.15512701869010925, 0.009352515451610088, -0.23010049760341644, 0.5756429433822632, 0.47555026412010193, -0.04795293137431145, -0.13051503896713257, -0.39134904742240906, -1.0348128080368042, 0.20038002729415894, -0.5049402713775635, -0.27438288927078247, -0.44227632880210876, 0.8906121850013733, -0.2084527611732483, 0.862763524055481, 0.5079965591430664, -0.07452651858329773, -0.08660577982664108, 0.7854368090629578, -0.007186018396168947, 0.19194355607032776, -0.9356658458709717, 0.8594565987586975, 0.2354705035686493, 0.07208334654569626, -1.0183491706848145, 0.07203312963247299, -0.8116388320922852, 0.1848638504743576, 1.1537185907363892, 0.26093995571136475, -1.235048532485962, 0.5947999358177185, -0.47482597827911377, 0.721386194229126, 0.26888248324394226, 0.11651177704334259, -0.5766749978065491, 0.08532289415597916, 0.11060653626918793, 0.15166711807250977, 0.2967241406440735, -0.03796738013625145, -0.7461531162261963, -0.33684849739074707, -0.5331271290779114, 0.4323665499687195, 0.3314889669418335, 0.808321475982666, 0.5151456594467163, 0.016277369111776352, 0.6810421943664551, 0.4806937575340271, 0.5226220488548279, 0.043974991887807846, -0.7319303154945374, 0.5770729780197144, -0.29208314418792725, 0.28098127245903015, -0.1796521246433258, 0.4857410788536072, -1.5359537601470947, 1.1185768842697144, -1.0525189638137817, 0.8386485576629639, 0.9787875413894653, 0.9264468550682068, -0.7481215000152588, 0.6263072490692139, 0.4189484417438507, 0.8399551510810852, 0.0600908063352108, -0.19167470932006836, 0.23247039318084717, 1.2198045253753662, -0.7352559566497803, -1.0350704193115234, -0.13704036176204681, 0.26274871826171875, -0.10042015463113785, 0.037827376276254654, 0.018023239448666573, -0.2759009599685669, -0.527565062046051, 0.3866523504257202, 0.2836623787879944, -0.07634168863296509, -0.6677007079124451, -0.3590916097164154, 0.2872943580150604, 1.2365139722824097, 0.1765989065170288, 0.00658317981287837, -0.470901757478714, -0.6401490569114685, -6.2287821769714355, -2.453052282333374}, {-0.6236937642097473, 0.056139227002859116, -0.6649568676948547, 0.22418874502182007, -0.6015364527702332, -0.0291010569781065, 1.1778565645217896, 1.3292732238769531, 0.8258090615272522, 1.4041731357574463, 0.5950585603713989, -0.1543172299861908, 0.13212710618972778, -0.09637434780597687, 0.21991704404354095, 0.29572218656539917, -0.28067925572395325, 0.22725015878677368, 0.20547549426555634, 0.9634106159210205, 0.18989251554012299, -0.028789013624191284, -0.45476770401000977, 0.08926790207624435, 0.029681509360671043, -0.8775092363357544, -0.26021280884742737, 0.3735564649105072, 0.0778576135635376, -0.03169181942939758, 1.3925062417984009, 0.40738826990127563, -0.5625453591346741, 0.3241405785083771, 0.4492715001106262, 0.343858540058136, -0.27861377596855164, -0.5265392661094666, 0.27662986516952515, 0.04968840256333351, -0.17845191061496735, -0.44219958782196045, -0.609743595123291, 0.06580565124750137, 0.4794926941394806, -0.3076293468475342, 0.5414518117904663, 0.25314149260520935, -0.8461079001426697, 0.03144664317369461, 0.15987685322761536, -0.20565852522850037, -0.4519275724887848, -0.03999423235654831, -0.7750672101974487, 0.7700462937355042, -0.25516098737716675, 0.049916017800569534, -0.30601394176483154, 0.4011140465736389, -0.7164904475212097, -1.038327932357788, -0.063483826816082, 0.06221355125308037, -0.8815211057662964, -0.12408820539712906, -0.019720764830708504, 0.38097986578941345, -0.43540480732917786, -0.6670851111412048, -0.8530758023262024, 0.3231176435947418, -1.807651400566101, 0.33950650691986084, -0.38657376170158386, -2.0899786949157715, 0.7745605707168579, -0.03993528336286545, -0.9698419570922852, 1.7647587060928345, -0.370869517326355, 0.4363529086112976, 0.10164415091276169, -0.23611022531986237, 0.09469203650951385, 0.6507559418678284, 1.129188895225525, -0.2215588241815567, -0.04031076654791832, 0.35177940130233765, -0.3573605418205261, -0.08923355489969254, 0.06587287038564682, -0.24341349303722382, 0.1785329133272171, 0.20207951962947845, -0.5184016823768616, -0.6899220943450928, -0.46610522270202637, 0.6925320029258728, 0.31908974051475525, 0.295026570558548, -0.026287244632840157, 0.7781999707221985, 0.34230837225914, -0.17562048137187958, -0.10604695975780487, 0.345167338848114, -6.663436412811279, -1.002687692642212}, {0.32745230197906494, 2.061122179031372, 1.1033841371536255, 0.0986822172999382, 0.13729475438594818, 1.4063704013824463, 0.4954403042793274, -0.5898532271385193, 1.4185317754745483, -0.28847047686576843, 0.24634651839733124, -0.546023428440094, 0.19134043157100677, 0.9003797173500061, 0.38454553484916687, -0.18678955733776093, 0.4332974851131439, 0.8761895298957825, 0.7138209342956543, -0.355175256729126, 0.6769099831581116, -0.5856716632843018, -0.37330901622772217, -1.1119937896728516, 0.5604730248451233, -1.044280767440796, -0.1826416403055191, -0.3287114202976227, 0.9280952215194702, 1.5211727619171143, 1.3989566564559937, 0.31058835983276367, 0.22177687287330627, -2.014838933944702, 0.00656735198572278, -0.222025528550148, -0.14141397178173065, 1.168332576751709, 0.43521907925605774, 0.6539240479469299, 0.002292485209181905, -0.6048069000244141, 1.213266134262085, 0.44047072529792786, 0.13159488141536713, -0.6108200550079346, 0.038815151900053024, -0.17471612989902496, 1.0060465335845947, 0.041010916233062744, 0.07754267752170563, -0.03509996458888054, 0.8698781728744507, 1.2688016891479492, -0.6328334808349609, -0.00015645996609237045, 0.16613087058067322, -1.4965077638626099, -0.23137585818767548, 0.11911822855472565, 1.3763467073440552, -0.4390745162963867, -0.09606096148490906, -1.379062294960022, -0.05583323538303375, 0.07543756067752838, 0.8471574187278748, -0.12873800098896027, 0.15657411515712738, -0.6782029867172241, -0.13862423598766327, 0.032973650842905045, -2.8462188243865967, 1.0270243883132935, 0.4956778287887573, -1.078748106956482, 0.5161455869674683, -0.7336804866790771, 0.7046306729316711, 0.2969975173473358, 0.9425216317176819, -1.1808748245239258, 0.027990493923425674, -0.09306001663208008, -1.2372905015945435, 0.4483258128166199, 1.1465880870819092, -0.5168546438217163, -0.42941319942474365, 0.5294370651245117, 0.39138004183769226, -1.2137583494186401, 0.5485923290252686, -0.4446222484111786, -0.4286732077598572, -0.09536871314048767, -1.9549616575241089, -0.6849513649940491, -0.76180100440979, -0.9897398352622986, -0.4529976546764374, -0.6365776062011719, 0.37204739451408386, 0.5892031192779541, 0.9760478734970093, -1.110390067100525, -0.19850291311740875, -0.6701620221138, -0.21980540454387665, 0.623195230960846}, {-0.011242417618632317, 0.6970837116241455, 0.9344095587730408, -0.06898798048496246, 1.371811866760254, 1.216322660446167, -1.0028327703475952, -0.5649392008781433, -0.08003455400466919, -0.2693057656288147, 0.423421174287796, 0.2184707671403885, -0.35117307305336, 0.42812779545783997, 0.9449825882911682, -1.082589030265808, 0.7727370858192444, -0.1948382407426834, 0.045140862464904785, 0.16077397763729095, -0.09831414371728897, 0.02418980374932289, 0.4944764971733093, -0.676487147808075, 0.07025700062513351, 0.3342665433883667, 1.9755845069885254, -0.8785991668701172, 0.6192609071731567, 1.0336904525756836, -1.051265835762024, -0.27624985575675964, 1.0667728185653687, -0.4440501928329468, 0.3238638639450073, -1.2229405641555786, 0.16449975967407227, 0.9329207539558411, 1.4507874250411987, -0.37683606147766113, 0.4395616054534912, 0.6483136415481567, 0.03778546303510666, -0.6342145204544067, 0.11888523399829865, -0.01556788943707943, -0.22543781995773315, -0.2314763367176056, -0.22383280098438263, 0.35469111800193787, 0.4987773597240448, -0.11022312939167023, 0.7512273192405701, -0.40248626470565796, 0.2781464159488678, -0.3240087628364563, 0.7503466606140137, -0.08789996057748795, 0.3734759986400604, -1.2486145496368408, 0.6471224427223206, -0.12095356732606888, -0.3587305247783661, 0.1755753457546234, 0.8794040679931641, 0.5791277885437012, -0.4483659565448761, -0.026260579004883766, -0.04746837168931961, 0.4061216711997986, 1.124007225036621, -0.280124694108963, 0.6988691091537476, 1.3204177618026733, 1.2180287837982178, 1.1551603078842163, -0.037392497062683105, -0.25093263387680054, 0.4686097204685211, -1.2417502403259277, 0.25740593671798706, -0.06343024969100952, 0.6748384237289429, -1.1430636644363403, 0.11115141212940216, 0.9707278609275818, 0.611701250076294, 0.1869582086801529, 0.5415437817573547, -0.06452728807926178, -0.1012905091047287, -0.8808248043060303, 0.0251642893999815, -0.28924670815467834, 0.8611404895782471, -0.24184240400791168, 1.1767995357513428, 0.06648965179920197, 0.8269761800765991, -0.22316834330558777, 0.2182869017124176, 0.07825679332017899, 0.4355733394622803, -1.102851390838623, 0.24241183698177338, 0.2251213937997818, 0.08815056830644608, 0.1046777218580246, -1.9053950309753418, -4.174374580383301}, {-0.3545818626880646, -0.6824375987052917, -0.05486447364091873, -0.590522825717926, -0.6563117504119873, 0.3369520306587219, -1.4480476379394531, -0.604686975479126, -0.2000761330127716, -0.958491861820221, -1.2629281282424927, -0.04626569524407387, 0.10172855854034424, -0.3355092704296112, -0.5014234185218811, 0.1481296569108963, -0.5778608322143555, -1.00905179977417, 0.027303554117679596, -0.1946900337934494, 0.001973087666556239, 0.7029587030410767, 0.06621506065130234, 0.29606661200523376, 0.6615598797798157, 1.3146647214889526, 0.04570740833878517, 0.10616672784090042, -2.628807306289673, -0.7919512987136841, 0.38236987590789795, -0.43389278650283813, -0.7771813869476318, 1.3056215047836304, 1.4683030843734741, 0.5567833185195923, 0.5253691077232361, 0.21670503914356232, -0.6426641941070557, 0.12662357091903687, -0.24598561227321625, -0.19591931998729706, -0.254036545753479, -0.8250237107276917, 0.7035639882087708, -0.48949822783470154, -0.20670495927333832, 0.22261732816696167, 0.2678527534008026, -0.28721606731414795, 0.21613800525665283, -0.4666154384613037, -1.0762312412261963, -0.3922910690307617, 0.24120691418647766, -0.33267197012901306, 0.6374896764755249, -0.354372501373291, 0.11268404871225357, 0.6311501860618591, 1.2351064682006836, -0.16194427013397217, -0.24626468122005463, 1.0507144927978516, -2.3147857189178467, -0.02002778835594654, -0.23856091499328613, 0.016737403348088264, -0.04231489822268486, 1.279403805732727, 1.8240870237350464, 0.19329684972763062, 0.2487984597682953, 0.4464462399482727, 0.24149078130722046, -2.0948052406311035, 0.07166246324777603, 1.5957329273223877, 0.11573214083909988, 0.9454392790794373, -0.09821891784667969, 0.7475365996360779, 0.01980520412325859, 0.5578694343566895, 1.4662580490112305, -0.466543048620224, 0.5562613010406494, 0.9409960508346558, -1.2632761001586914, -0.2726801335811615, 0.7691190838813782, 0.6508200168609619, -0.059519633650779724, 1.4619249105453491, 0.252429723739624, 0.38969552516937256, -2.710455894470215, -0.4460744261741638, -0.7447630167007446, 0.8245142698287964, -1.1361850500106812, 0.3306448459625244, -0.29345399141311646, 1.3298661708831787, 0.7316357493400574, 1.1272236108779907, 0.0745711550116539, 0.7245745658874512, 0.8559451103210449, 0.12165705114603043}, {0.6442310810089111, 0.2734476327896118, -0.7297450304031372, -0.25569629669189453, -0.64133220911026, 0.1794871687889099, 0.03968099132180214, -0.04302607849240303, -0.01527371909469366, 0.9907929301261902, -1.4246907234191895, 0.8198570013046265, 0.19634239375591278, -0.2787831723690033, -0.90791255235672, 0.2593283951282501, -0.3454883098602295, 0.044641561806201935, 0.342410683631897, 0.15762652456760406, -0.38894885778427124, 0.9655144810676575, -1.3150849342346191, 0.4543429911136627, -0.21170520782470703, 0.8045044541358948, -0.40748801827430725, -0.18185767531394958, 0.1958637684583664, 0.4011032283306122, 0.10491450130939484, -0.21721573173999786, -0.11030114442110062, 0.7364212870597839, -1.5131975412368774, 0.3981367349624634, -0.7191420793533325, 0.2682417333126068, -0.6644414663314819, 0.18448153138160706, -0.209454745054245, 0.2356238067150116, 0.1272117644548416, 0.17012831568717957, -0.5331333875656128, 1.1399105787277222, 0.1047845333814621, 0.5939695835113525, -0.24596159160137177, -0.05359923467040062, -0.4156453311443329, 0.647851288318634, -0.35239240527153015, 0.18862773478031158, 0.06089188903570175, 0.16307340562343597, -0.7976985573768616, 0.8121605515480042, -0.33449268341064453, 0.7256109714508057, -1.5798479318618774, -0.03702820464968681, -0.41405364871025085, 0.13951434195041656, -0.38347065448760986, 0.363116979598999, 0.043230488896369934, 0.790820837020874, -0.4545191526412964, -0.017825797200202942, -1.0147243738174438, 1.014445424079895, -0.7281822562217712, 0.3302992582321167, -0.22377878427505493, -0.6465916633605957, -0.32434675097465515, -0.7943945527076721, -0.6783803105354309, 0.2094704806804657, -0.5424997806549072, 0.620915949344635, 0.03601590171456337, 0.6937717199325562, -1.7787312269210815, 0.7054867148399353, -0.8957505226135254, -0.6601713299751282, -0.34765005111694336, -0.15949374437332153, -0.4896394908428192, 0.049654990434646606, -0.9706451296806335, 0.6957705616950989, 0.14879055321216583, 0.8515923023223877, -1.6833875179290771, 0.1120946854352951, -0.6026744246482849, -1.198235273361206, -0.09060953557491302, -0.39946430921554565, -0.1237773671746254, 0.7228837013244629, -0.4718933403491974, 0.44367504119873047, -0.5287284255027771, 1.0936741828918457, 5.775559902191162, 1.3819942474365234}, {-0.6843695640563965, 1.9671112298965454, 0.6355276107788086, 0.357645720243454, -0.7062849402427673, -2.095897674560547, -0.29778343439102173, 0.39148393273353577, -0.3457568287849426, 0.4529300332069397, 0.5803347229957581, -2.8869104385375977, 0.16142919659614563, -4.5634565353393555, -0.36400479078292847, -0.27429133653640747, 0.08801768720149994, -0.1558474600315094, 0.01590747758746147, -0.6335160732269287, -0.9659391641616821, -0.274513840675354, -5.662142753601074, 0.6800422668457031, 1.3208622932434082, 1.9170011281967163, -0.13428469002246857, 0.15895068645477295, -0.16067729890346527, -1.3352599143981934, -1.867932915687561, 0.22946840524673462, -0.4968302547931671, -0.001771705225110054, 1.5744564533233643, -0.8716257214546204, 0.7159427404403687, -0.10337327420711517, 1.2570980787277222, -0.23009680211544037, 0.48282065987586975, 0.7873317003250122, -0.8051977753639221, 0.2665348947048187, 0.5357442498207092, -0.7180758714675903, 0.24835197627544403, -0.3950732946395874, -0.33878153562545776, -0.2524719536304474, 0.39071014523506165, -0.5008668899536133, -0.0866008847951889, -0.11366541683673859, -0.05183246731758118, 0.10090695321559906, -0.30401337146759033, 0.3025892674922943, 0.15951772034168243, -0.05533163622021675, 1.0859756469726562, 0.8895078301429749, 0.5576184391975403, 0.3466758131980896, 0.4007216691970825, -0.44849273562431335, -0.1171148493885994, -0.036167241632938385, 0.4328608214855194, -0.010532478801906109, -0.5647966861724854, -1.6450928449630737, 0.46712324023246765, 0.20650437474250793, 1.0117689371109009, 0.22195760905742645, 0.04947790503501892, 0.7530243992805481, 1.853662371635437, -0.7355844974517822, -0.2112749218940735, -0.3170221447944641, 0.5251079797744751, -0.484696626663208, 0.31642550230026245, 0.09187614917755127, 0.5886988043785095, -0.15747623145580292, 0.10241830348968506, -0.1055864542722702, 0.24922552704811096, 0.287695974111557, 0.2961241602897644, -0.3016272187232971, -0.5953752398490906, -0.5401706099510193, 0.985068678855896, -0.2609187662601471, 0.7651111483573914, 0.054146312177181244, 1.1620020866394043, 0.3911398649215698, 0.3165219724178314, -0.5469945073127747, 0.3889983594417572, -0.1125200018286705, -0.2581467032432556, -1.0459898710250854, -0.8223215341567993, 1.5610430240631104}};
-const float dense1_biases[DENSE1_NUM] =
+float dense1_biases[DENSE1_NUM] =
{-0.559496283531189, -0.1259697526693344, 0.5167818069458008, -0.07613079249858856, 0.016916882246732712, 0.562254011631012, 0.2608274519443512, 0.2632611393928528, 0.019986296072602272, -0.2393009513616562, 0.7170191407203674};
-const float dense2_weights[DENSE2_NUM][DENSE1_NUM] =
+float dense2_weights[DENSE2_NUM][DENSE1_NUM] =
{{0.5795437097549438, -0.23521320521831512, 0.6527981162071228, 0.3215695321559906, -0.996798038482666, -1.2032746076583862, 1.096634864807129, -1.5764343738555908, -0.4597227871417999, 0.11940335482358932, 0.5662763118743896}, {-0.28216224908828735, 0.678406834602356, -0.13064861297607422, -0.03267639875411987, 0.9620053768157959, 1.1100767850875854, -0.2703317105770111, -0.07297029346227646, 0.30354833602905273, 0.33620086312294006, -0.1602449119091034}, {-0.37449052929878235, -0.2131105661392212, 0.01748967356979847, -0.04315502569079399, -0.27067434787750244, -0.24308127164840698, -0.4979601800441742, 0.2982286810874939, 0.1693423092365265, -0.45516952872276306, -0.8959820866584778}, {0.04494471475481987, -0.43003126978874207, -0.036062583327293396, 0.4107465147972107, -0.8443616628646851, -0.5406489968299866, 0.3919742703437805, 0.6312925815582275, -0.43831726908683777, -0.806746244430542, 0.30192217230796814}, {-0.4748700261116028, 0.6956803798675537, -0.2491106390953064, 0.002321340376511216, -0.8060805201530457, 0.014423917979001999, -0.6640377044677734, -0.345352441072464, 0.5939163565635681, 1.16130530834198, -0.34093284606933594}, {-0.27627506852149963, -0.23001135885715485, -0.24849137663841248, 0.049682945013046265, 0.470129132270813, -1.4751933813095093, -0.19170530140399933, -0.6249161958694458, 1.1539117097854614, 1.2065660953521729, -0.1641182154417038}, {1.0805885791778564, -0.6379875540733337, 0.9749761819839478, -0.2782149016857147, -0.7396007776260376, -0.6217549443244934, 0.03215833008289337, -0.5615314245223999, 0.0847288966178894, -0.18291589617729187, 0.37245139479637146}, {0.8723656535148621, -0.5074524283409119, 0.6540945172309875, 0.029449354857206345, -0.3518807291984558, -0.32012519240379333, 0.5382040739059448, 0.5741275548934937, -0.20223835110664368, -0.15425445139408112, 0.7062283754348755}};
-const float dense2_biases[DENSE2_NUM] =
+float dense2_biases[DENSE2_NUM] =
{1.2298400402069092, 0.8133684992790222, 2.3766794204711914, 1.469264030456543, 1.2461377382278442, 0.29813963174819946, 0.2597852349281311, 0.34889695048332214};
-const float output_weights[DENSE2_NUM] =
+float output_weights[DENSE2_NUM] =
{0.3434557020664215, -0.18194633722305298, 0.17597387731075287, 0.11844130605459213, -0.2467159777879715, -0.16700856387615204, 0.11766894161701202, 0.18488647043704987};
-const float output_bias =
+float output_bias =
0.027359746396541595;
diff --git a/include/weights.h b/include/weights.h
index f736198..3d655e5 100644
--- a/include/weights.h
+++ b/include/weights.h
@@ -24,11 +24,17 @@
#define KERN_OSIZE (5-KERN_SIZE+1) // 5
#define CONV_NUM (KERN_NUM * KERN_OSIZE * KERN_OSIZE) // 108
-extern const float conv2d_weights[KERN_NUM][KERN_SIZE][KERN_SIZE][KERN_CHAN];
-extern const float conv2d_biases[KERN_NUM];
-extern const float dense1_weights[DENSE1_NUM][CONV_NUM+2];
-extern const float dense1_biases[DENSE1_NUM];
-extern const float dense2_weights[DENSE2_NUM][DENSE1_NUM];
-extern const float dense2_biases[DENSE2_NUM];
-extern const float output_weights[DENSE2_NUM];
-extern const float output_bias;
+#define NUM_PARAMETERS \
+(KERN_NUM * KERN_SIZE * KERN_SIZE * KERN_CHAN + KERN_NUM \
+ + DENSE1_NUM * (CONV_NUM + 2) + DENSE1_NUM \
+ + DENSE2_NUM * DENSE1_NUM + DENSE2_NUM \
+ + DENSE2_NUM + 1)
+
+extern float conv2d_weights[KERN_NUM][KERN_SIZE][KERN_SIZE][KERN_CHAN];
+extern float conv2d_biases[KERN_NUM];
+extern float dense1_weights[DENSE1_NUM][CONV_NUM+2];
+extern float dense1_biases[DENSE1_NUM];
+extern float dense2_weights[DENSE2_NUM][DENSE1_NUM];
+extern float dense2_biases[DENSE2_NUM];
+extern float output_weights[DENSE2_NUM];
+extern float output_bias;
diff --git a/src/ctnn.c b/src/ctnn.c
new file mode 100644
index 0000000..49a9659
--- /dev/null
+++ b/src/ctnn.c
@@ -0,0 +1,336 @@
+/*
+ ctnn, neural network harness (generate training data, self-play
+ training, evaluate accuracy) using a playtak.com database
+
+ Copyright (C) 2021, tslil clingman
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include <cnn1986.h>
+#include <negamax.h>
+#include <tak.h>
+
+#define RANDPM1 ((rand()&1)?-1:+1)
+
+enum MODE { M_RPT, M_EVL, M_GEN, M_TRN };
+
+enum MODE mode;
+FILE *training_fh = NULL;
+uint64_t heights[16], samples;
+float max_flats, outcome_black, loss;
+
+// Self-play parameters
+float lambda = 0.7;
+int num_training_plies = 5;
+
+const int max_depth = 6;
+inline void
+negamax_display_progress(const uint8_t cur_depth,
+ const uint8_t init_depth,
+ const uint32_t length) {
+ (void)(cur_depth);
+ (void)(init_depth);
+ (void)(length);
+}
+
+static void
+write_input(const int dx, const int dy, const uint8_t swap) {
+ // Two numbers for flats remaining
+ fprintf(training_fh,"%.8f,%.8f,",
+ (float)(white_count & 127)/max_flats,
+ (float)(black_count & 127)/max_flats);
+
+ // Write the board layers
+ float val;
+ int col, row;
+ for (uint8_t depth = 0; depth < max_depth; depth++) {
+ row = (dy>0)?-1:board_size;
+ for (int i = 0; i < board_size; i++) {
+ row += dy;
+ col = (dx>0)?-1:board_size;
+ for (int j = 0; j < board_size; j++) {
+ col += dx;
+ const uint8_t k =
+ (swap) ? THE_COORDS(row, col) : THE_COORDS(col, row);
+ val = 0;
+ if (COUNT_AT(k)>depth) {
+ if (depth == 0) {
+ // Top layer of stacks is handled differently to indicate
+ // stone type
+ if (STONE_AT(k) == STONE_STANDING) {
+ val = (colours[k] & 1) ? +0.25 : -0.25;
+ } else if (STONE_AT(k) == STONE_CAPSTONE) {
+ val = (colours[k] & 1) ? +1.00 : -1.00;
+ } else {
+ val = (colours[k] & 1) ? +0.75 : -0.75;
+ }
+ } else {
+ // Layers underneath
+ val = (colours[k] & (1<<depth)) ? +0.75 : -0.75;
+ }
+ }
+ fprintf(training_fh,"%.2f,", val);
+ }
+ }
+ }
+ fprintf(training_fh,"%.1f\n", outcome_black);
+}
+
+// Warning: performs _no_ checks on input whatsoever
+static enum ACT_RESULT
+parse_line(const char *pt, const ssize_t read) {
+ ssize_t idx;
+ enum ACT_RESULT r;
+ int total_plies = 0;
+
+ for (idx=0;idx<read;idx++) {
+ if (pt[idx]==',') total_plies++;
+ }
+
+ const uint8_t this_game_ply = total_plies - num_training_plies;
+
+ for(idx=0;;) {
+ if (pt[idx] == 'P') {
+ // P [A-F][1-6] [CF]?,
+ idx+=2;
+ enum STONE_VARIANT stone;
+ const uint8_t col = pt[idx]-'A', row = pt[idx+1]-'1';
+
+ if (idx + 3 < read) {
+ switch (pt[idx+3]) {
+ case 'W': { stone = STONE_STANDING; break; }
+ case 'C': { stone = STONE_CAPSTONE; break; }
+ default: { stone = STONE_FLAT; break; }
+ }
+ } else {
+ stone = STONE_FLAT;
+ }
+
+ r = try_place(THE_COORDS(col,row), current_colour, stone);
+ if (r != ACT_OK) return r;
+ } else if (pt[idx] == 'M') {
+ // M [A-F][1-6] [A-F][1-6]( [1-6])+,
+ idx+=2;
+ uint8_t drops[board_size];
+ const uint8_t s_col =pt[idx]-'A', s_row=pt[idx+1]-'1',
+ d_col=pt[idx+3]-'A', d_row=pt[idx+4]-'1';
+ idx+=4;
+
+ enum MOVE_DIRECTION dir = M_RIGHT;
+ if (s_col < d_col) dir=M_RIGHT;
+ else if (s_col > d_col) dir=M_LEFT;
+ else if (s_row < d_row) dir=M_UP;
+ else if (s_row > d_row) dir=M_DOWN;
+
+ uint8_t steps = 0;
+ do {
+ idx+=2;
+ drops[steps++] = pt[idx] - '0';
+ } while (idx+2<read && pt[idx+1] != ',');
+
+ r = try_move(THE_COORDS(s_col, s_row), dir, steps, drops);
+
+ if (r != ACT_OK) return r;
+
+ if (mode == M_RPT) {
+ // Measure height of stacks exceeding 1
+ for (int k = 0; k < board_size * board_size; k++) {
+ if (COUNT_AT(k)>1) heights[COUNT_AT(k)]+=1;
+ }
+ }
+ }
+ switch (mode) {
+ case M_RPT: break;
+ case M_GEN: {
+ if (ply + 3 >= total_plies)
+ write_input(RANDPM1, RANDPM1, rand()&1);
+ break;
+ };
+ case M_EVL: {
+ if (ply + 3 >= total_plies) {
+ samples++;
+ loss += fabsf(cnn1986_evaluate_black_win() - outcome_black);
+ }
+ break;
+ }
+ case M_TRN: {
+ if (ply == this_game_ply) {
+ float jd[num_training_plies], grad_jd[num_training_plies][NUM_PARAMETERS];
+ enum WIN_TYPE w;
+ int n;
+
+ for (n = 0; n < num_training_plies; n++) {
+ jd[n] = negamax_generate();
+ cnn1986_compute_gradient();
+ for (int j = 0; j < NUM_PARAMETERS; j++)
+ grad_jd[n][j] = cnn1986_gradient[j];
+
+ if (do_ptn(negamax_ptn) == ACT_OK) {
+ if ((w = check_win()) < 0xFF) {
+ // Correct the entry
+ if (w == WIN_FLAT_BLACK || w == WIN_ROAD_BLACK)
+ jd[n] = +1;
+ else if (w == WIN_FLAT_WHITE || w == WIN_ROAD_WHITE)
+ jd[n] = -1;
+ else
+ jd[n] = 0;
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+
+ float ds[n];
+ for (int k = 0; k < n; k++) ds[k] = jd[k+1] - jd[k];
+
+ }
+ break;
+ }
+ }
+
+ // Parse next action
+ while (idx<read && pt[idx++]!=',');
+ if (idx>=read) return ACT_OK;
+ next_ply();
+ }
+ return ACT_OK;
+}
+
+const char* license = "ctnn, neural network harness (generate training data, self-play training, evaluate accuracy) using a playtak.com database\n\
+\n\
+Copyright (C) 2021, tslil clingman\n\
+\n\
+This program comes with ABSOLUTELY NO WARRANTY; and is made available under the terms of the GNU GPL v3 license. This is free software, and you are welcome to redistribute it under certain conditions; see COPYING for details.\n";
+
+int main(int argc, char **argv) {
+ (void)(argc);
+
+ enum ACT_RESULT r;
+ enum WIN_TYPE win;
+ uint32_t games = 0, overflow=0, illegal = 0;
+ uint32_t road_wins=0, flat_wins=0, road_turns=0, flat_turns=0,
+ white_wins = 0, black_wins = 0;
+
+ for (int k = 0; k < 16; k++) heights[k] = 0;
+
+ size_t len = 0;
+ ssize_t read = 0;
+ FILE *playtak_fh = NULL;
+ char *line = NULL, td_fn[65];
+
+ const uint8_t size = argv[1][0]-'0';
+ max_flats = (size == 5) ? 21.0 : 30.0;
+
+ playtak_fh = fopen(argv[2], "r");
+ if (playtak_fh == NULL) exit(EXIT_FAILURE);
+
+ mode = M_RPT;
+ if (argc > 3) {
+ if (!strncmp("generate", argv[3], 8)) {
+ mode = M_GEN;
+ snprintf(td_fn, 64, "data/training-%d.csv", size);
+ training_fh = fopen(td_fn, "w");
+ if (training_fh == NULL) exit(EXIT_FAILURE);
+ } else if (!strncmp("train", argv[3], 5)) {
+ mode = M_TRN;
+ } else if (!strncmp("evaluate", argv[3], 8)) {
+ loss = 0;
+ samples = 0;
+ mode = M_EVL;
+ }
+ }
+
+ while ((read = getline(&line, &len, playtak_fh)) != -1) {
+ // Reset everything
+ reset_state(size);
+ // Store the outcome of this game. Black win = 0.9
+ if (line[read-4] == '0') outcome_black = 0.9;
+ else outcome_black = -0.9;
+ // Parse the line
+ r = parse_line(line,read-4);
+ // Adjust counts if we're not generating training data
+ if (mode == M_RPT) {
+ if (r == ACT_ILLEGAL) {
+ illegal++;
+ printf("Illegal:\n%s",line);
+ } else if (r == ACT_OVERFLOW) {
+ printf("Overflow:\n%s",line);
+ overflow++;
+ } else {
+ win = check_win();
+ if (win == WIN_FLAT_BLACK
+ || win == WIN_FLAT_WHITE
+ || win == WIN_DRAW) {
+ flat_wins++;
+ flat_turns += ply/2+1;
+ } else {
+ road_wins++;
+ road_turns += ply/2+1;
+ }
+ if (win == WIN_FLAT_BLACK || win == WIN_ROAD_BLACK)
+ black_wins++;
+ else if (win == WIN_FLAT_WHITE || win == WIN_ROAD_WHITE)
+ white_wins++;
+ }
+ }
+ games++;
+ }
+
+ fclose(playtak_fh);
+ if (mode == M_GEN) fclose(training_fh);
+ if (line) free(line);
+
+ if (illegal || overflow) putchar('\n');
+ printf("Read %d games\n",games);
+
+
+ switch (mode) {
+ case M_RPT: {
+ printf("Illegals: %d\nOverflows: %d\n\
+Black wins: %.3f%%\n\
+Road wins: %d\nFlat wins: %d\n\
+Average turns to road win: %.3f\n\
+Average turns to flat win: %.3f\n",
+ illegal, overflow,
+ (double)black_wins / (double)(black_wins+white_wins) * 100,
+ road_wins, flat_wins,
+ (double)(road_turns)/(double)(road_wins),
+ (double)(flat_turns)/(double)(flat_wins));
+ for (int k = 2; k < 16; k++) {
+ printf("Height %2d: %7ld\n",k,heights[k]);
+ }
+ break;
+ }
+ case M_EVL: {
+ printf("%ld samples: %.8f loss\n",
+ samples, loss / ((float)(samples)));
+ break;
+ }
+ case M_TRN: {
+ break;
+ }
+ case M_GEN: {
+ break;
+ }
+ }
+
+ exit(EXIT_SUCCESS);
+}