From ee216c008a188a9436fedb85c70ee5d1719733b1 Mon Sep 17 00:00:00 2001 From: tslil clingman Date: Sun, 15 Jan 2023 16:03:37 +0100 Subject: new neural network arch (faster + better) & minor changes + fixes Gone is the convolutional neural network, for it turns out not only is it more difficult to train, but all of the extra information about board layers didn't make much of a difference at this size. So cnn1986 has been replaced by nn1986, a standard, two-layer, dense nn configured as a binary classifier and (mis)used in that capacity. Note: total number of parameters is unchanged. HARK: this new nn exposes a bug somewhere in ctak. Run ctlm with self-play to see the completely borked board state at the end. --- .clang_complete | 1 - .gitignore | 2 + Makefile | 2 +- README.md | 24 +++- compile_commands.json | 254 +++++++++++++++++++++++++++++++++++ include/cnn1986.c | 131 ------------------ include/cnn1986.h | 20 --- include/negamax.c | 232 ++++++++++++++++---------------- include/negamax.h | 6 +- include/nn1986.c | 81 +++++++++++ include/nn1986.h | 20 +++ include/weights.c | 57 ++++---- include/weights.h | 21 +-- resources/extract.sh | 89 ++++++------- src/cnn_train.py | 156 ---------------------- src/ctlm.c | 54 ++++---- src/cttei.c | 26 ++-- src/nn_train.py | 106 +++++++++++++++ src/pptdb.c | 361 +++++++++++++++++++++++++------------------------- 19 files changed, 892 insertions(+), 751 deletions(-) delete mode 100644 .clang_complete create mode 100644 compile_commands.json delete mode 100644 include/cnn1986.c delete mode 100644 include/cnn1986.h create mode 100644 include/nn1986.c create mode 100644 include/nn1986.h delete mode 100644 src/cnn_train.py create mode 100644 src/nn_train.py diff --git a/.clang_complete b/.clang_complete deleted file mode 100644 index 3e2e760..0000000 --- a/.clang_complete +++ /dev/null @@ -1 +0,0 @@ --Iinclude/ diff --git a/.gitignore b/.gitignore index c8a996d..bf3831d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ ct1986 ctlm pptdb cttei +geminict buildroot* +.cache diff --git a/Makefile b/Makefile index 0fa5237..5303448 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ IDIR=include DEFINES=-DDETERMINISTIC -CFLAGS=-O3 --fast-math -Wall -Wextra -Wpedantic -std=c99 -D_DEFAULT_SOURCE $(DEFINES) -I$(IDIR) +CFLAGS=-O3 -ffast-math -Wall -Wextra -Wpedantic -std=c99 -D_DEFAULT_SOURCE $(DEFINES) -I$(IDIR) CTAK=include/tak.c CTAK_OBJS=$(CTAK:.c=.o) diff --git a/README.md b/README.md index ea0e172..9f18cad 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Details forthcoming, but at a glance: ## Building for the native platform - make native + make native ## Building for the Raspberry Pi Zero @@ -20,17 +20,29 @@ Download and extract a recent version of buildroot into the working directory. Edit `BUILDROOT_DIR=buildroot-2020.11.1` in `Makefile` to point to the extracted directory. - make pi + make pi ## The computer opponent -### Adversarial tree search implementation +Standard adversarial tree search (α-β negamax) with iterative deepening, using a neural network evaluation function for leaves and also transposition tables implemented using Zobrist hasing and a chaining hash table. -Details coming soon +The architecture of the neural network is a standard, two-layer dense classification network +``` +_________________________________________________________________ + Layer (type) Output Shape Param # +================================================================= + input_1 (InputLayer) [(None, 28)] 0 -### The convolutional neural network cnn1986 + dense (Dense) (None, 64) 1856 -Details coming soon + dense_1 (Dense) (None, 2) 130 + +================================================================= +Total params: 1,986 +Trainable params: 1,986 +Non-trainable params: 0 +``` +which was trained on the binary classification problem of predicting the winner from a given board state. As input the network is fed the top layer of the board only (see nn1986.c for details) as well as `flats used/flats remaining` fractions for both players and a single float indicating the parity of the board. At the time of training, on the dataset given by `resources/extract.sh`, this achieves ~82% accuracy on the validation set. ## License diff --git a/compile_commands.json b/compile_commands.json new file mode 100644 index 0000000..69359af --- /dev/null +++ b/compile_commands.json @@ -0,0 +1,254 @@ +[ + { + "arguments": [ + "/usr/bin/cc", + "-c", + "-O3", + "-ffast-math", + "-Wall", + "-Wextra", + "-Wpedantic", + "-std=c99", + "-D_DEFAULT_SOURCE", + "-DDETERMINISTIC", + "-Iinclude", + "-o", + "src/ctlm.o", + "src/ctlm.c" + ], + "directory": "/home/tslil/code/ctak", + "file": "/home/tslil/code/ctak/src/ctlm.c", + "output": "/home/tslil/code/ctak/src/ctlm.o" + }, + { + "arguments": [ + "/usr/bin/cc", + "-c", + "-O3", + "-ffast-math", + "-Wall", + "-Wextra", + "-Wpedantic", + "-std=c99", + "-D_DEFAULT_SOURCE", + "-DDETERMINISTIC", + "-Iinclude", + "-o", + "include/actions.o", + "include/actions.c" + ], + "directory": "/home/tslil/code/ctak", + "file": "/home/tslil/code/ctak/include/actions.c", + "output": "/home/tslil/code/ctak/include/actions.o" + }, + { + "arguments": [ + "/usr/bin/cc", + "-c", + "-O3", + "-ffast-math", + "-Wall", + "-Wextra", + "-Wpedantic", + "-std=c99", + "-D_DEFAULT_SOURCE", + "-DDETERMINISTIC", + "-Iinclude", + "-o", + "include/cnn1986.o", + "include/cnn1986.c" + ], + "directory": "/home/tslil/code/ctak", + "file": "/home/tslil/code/ctak/include/cnn1986.c", + "output": "/home/tslil/code/ctak/include/cnn1986.o" + }, + { + "arguments": [ + "/usr/bin/cc", + "-c", + "-O3", + "-ffast-math", + "-Wall", + "-Wextra", + "-Wpedantic", + "-std=c99", + "-D_DEFAULT_SOURCE", + "-DDETERMINISTIC", + "-Iinclude", + "-o", + "include/negamax.o", + "include/negamax.c" + ], + "directory": "/home/tslil/code/ctak", + "file": "/home/tslil/code/ctak/include/negamax.c", + "output": "/home/tslil/code/ctak/include/negamax.o" + }, + { + "arguments": [ + "/usr/bin/cc", + "-c", + "-O3", + "-ffast-math", + "-Wall", + "-Wextra", + "-Wpedantic", + "-std=c99", + "-D_DEFAULT_SOURCE", + "-DDETERMINISTIC", + "-Iinclude", + "-o", + "include/tak.o", + "include/tak.c" + ], + "directory": "/home/tslil/code/ctak", + "file": "/home/tslil/code/ctak/include/tak.c", + "output": "/home/tslil/code/ctak/include/tak.o" + }, + { + "arguments": [ + "/usr/bin/cc", + "-c", + "-O3", + "-ffast-math", + "-Wall", + "-Wextra", + "-Wpedantic", + "-std=c99", + "-D_DEFAULT_SOURCE", + "-DDETERMINISTIC", + "-Iinclude", + "-o", + "include/tps.o", + "include/tps.c" + ], + "directory": "/home/tslil/code/ctak", + "file": "/home/tslil/code/ctak/include/tps.c", + "output": "/home/tslil/code/ctak/include/tps.o" + }, + { + "arguments": [ + "/usr/bin/cc", + "-c", + "-O3", + "-ffast-math", + "-Wall", + "-Wextra", + "-Wpedantic", + "-std=c99", + "-D_DEFAULT_SOURCE", + "-DDETERMINISTIC", + "-Iinclude", + "-o", + "include/tt_llcht.o", + "include/tt_llcht.c" + ], + "directory": "/home/tslil/code/ctak", + "file": "/home/tslil/code/ctak/include/tt_llcht.c", + "output": "/home/tslil/code/ctak/include/tt_llcht.o" + }, + { + "arguments": [ + "/usr/bin/cc", + "-c", + "-O3", + "-ffast-math", + "-Wall", + "-Wextra", + "-Wpedantic", + "-std=c99", + "-D_DEFAULT_SOURCE", + "-DDETERMINISTIC", + "-Iinclude", + "-o", + "include/weights.o", + "include/weights.c" + ], + "directory": "/home/tslil/code/ctak", + "file": "/home/tslil/code/ctak/include/weights.c", + "output": "/home/tslil/code/ctak/include/weights.o" + }, + { + "arguments": [ + "/usr/bin/cc", + "-c", + "-O3", + "-ffast-math", + "-Wall", + "-Wextra", + "-Wpedantic", + "-std=c99", + "-D_DEFAULT_SOURCE", + "-DDETERMINISTIC", + "-Iinclude", + "-o", + "include/xorshift64.o", + "include/xorshift64.c" + ], + "directory": "/home/tslil/code/ctak", + "file": "/home/tslil/code/ctak/include/xorshift64.c", + "output": "/home/tslil/code/ctak/include/xorshift64.o" + }, + { + "arguments": [ + "/usr/bin/cc", + "-c", + "-O3", + "-ffast-math", + "-Wall", + "-Wextra", + "-Wpedantic", + "-std=c99", + "-D_DEFAULT_SOURCE", + "-DDETERMINISTIC", + "-Iinclude", + "-o", + "include/zobrist.o", + "include/zobrist.c" + ], + "directory": "/home/tslil/code/ctak", + "file": "/home/tslil/code/ctak/include/zobrist.c", + "output": "/home/tslil/code/ctak/include/zobrist.o" + }, + { + "arguments": [ + "/usr/bin/cc", + "-c", + "-O3", + "-ffast-math", + "-Wall", + "-Wextra", + "-Wpedantic", + "-std=c99", + "-D_DEFAULT_SOURCE", + "-DDETERMINISTIC", + "-Iinclude", + "-o", + "src/cttei.o", + "src/cttei.c" + ], + "directory": "/home/tslil/code/ctak", + "file": "/home/tslil/code/ctak/src/cttei.c", + "output": "/home/tslil/code/ctak/src/cttei.o" + }, + { + "arguments": [ + "/usr/bin/cc", + "-c", + "-O3", + "-ffast-math", + "-Wall", + "-Wextra", + "-Wpedantic", + "-std=c99", + "-D_DEFAULT_SOURCE", + "-DDETERMINISTIC", + "-Iinclude", + "-o", + "src/geminict.o", + "src/geminict.c" + ], + "directory": "/home/tslil/code/ctak", + "file": "/home/tslil/code/ctak/src/geminict.c", + "output": "/home/tslil/code/ctak/src/geminict.o" + } +] diff --git a/include/cnn1986.c b/include/cnn1986.c deleted file mode 100644 index 7c7dbcb..0000000 --- a/include/cnn1986.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - This file is part of ct. - - 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 ct. If not, see . -*/ - -#include "cnn1986.h" -#include "weights.h" - -// =================================================================== -// Implementation of a small convolutional neural network -// =================================================================== - -static float cur_board[5*5][KERN_CHAN]; -static float flattened[CONV_NUM+2]; -static float dense1[DENSE1_NUM]; -static float dense2[DENSE2_NUM]; - -#define RELU(x) ((x) = ((x)<0)?0:(x)) -float cnn1986_evaluate_black_win(void) { - /* --------------- * - * Populate input * - * --------------- */ - for (unsigned int y = 0; y < board_size; y++) { - for (unsigned int x = 0; x < board_size; x++) { - const unsigned int loc = x+y*board_size; - const unsigned int count = COUNT_AT(loc); - colour_stack_t colour = colours[loc]; - - if (count > 0) { - float lookup = 0; - if (STONE_AT(loc) == STONE_STANDING) { - lookup = (colour & 1) ? +0.25 : -0.25; - } else if (STONE_AT(loc) == STONE_CAPSTONE) { - lookup = (colour & 1) ? +1.00 : -1.00; - } else { - lookup = (colour & 1) ? +0.50 : -0.50; - } - cur_board[loc][0] = lookup; - - colour>>=1; - for (unsigned int c = 1; c < count && c < KERN_CHAN; c++, colour>>=1) { - cur_board[loc][c] = (colour & 1) ? +0.50 : -0.50; - } - - for (unsigned int c = count; c < KERN_CHAN; c++) { - cur_board[loc][c] = 0; - } - } else { - for (unsigned int c = 0; c < KERN_CHAN; c++) { - cur_board[loc][c] = 0; - } - } - } - } - /* ------------------ * - * Convolution layer * - * ------------------ */ - // for each kernel - for (unsigned int kern = 0; kern < KERN_NUM; kern++) { - // the stride is 1, march across the board - for (unsigned int bx = 0; bx < KERN_OSIZE; bx++) { - for (unsigned int by = 0; by < KERN_OSIZE; by++) { - flattened[kern+KERN_NUM*(bx+by*KERN_OSIZE)] = - conv2d_biases[kern]; - // Compute the convolution for this position - for (unsigned int ky = 0; ky < KERN_SIZE; ky++) { - for (unsigned int kx = 0; kx < KERN_SIZE; kx++) { - for (unsigned int c = 0; c < KERN_CHAN; c++) { - // Where we are on the board - const unsigned int loc = kx+bx+(ky+by)*board_size; - flattened[kern+KERN_NUM*(bx+by*KERN_OSIZE)] - += cur_board[loc][c]*conv2d_weights[kern][ky][kx][c]; - } - } - } - RELU(flattened[kern+KERN_NUM*(bx+by*KERN_OSIZE)]); - } - } - } - // Add input of flat counts - flattened[CONV_NUM] = (float)(white_count & 127)/21.0; - flattened[CONV_NUM+1] = (float)(black_count & 127)/21.0; - /* ------------------ * - * First dense layer * - * ------------------ */ - for (unsigned int d1 = 0; d1 < DENSE1_NUM; d1++) { - dense1[d1] = dense1_biases[d1]; - for (unsigned int fl = 0; fl < CONV_NUM+2; fl++) { - dense1[d1] += flattened[fl]*dense1_weights[d1][fl]; - } - RELU(dense1[d1]); - } - /* ------------------- * - * Second dense layer * - * ------------------- */ - for (unsigned int d2 = 0; d2 < DENSE2_NUM; d2++) { - dense2[d2] = dense2_biases[d2]; - for (unsigned int d1 = 0; d1 < DENSE1_NUM; d1++) { - dense2[d2] += dense1[d1]*dense2_weights[d2][d1]; - } - RELU(dense2[d2]); - } - /* ------------- * - * Output layer * - * ------------- */ - float output = output_bias; - for (unsigned int d2 = 0; d2 < DENSE2_NUM; d2++) { - output += dense2[d2]*output_weights[d2]; - } - // 2*(clamped Pade approximant of logistic function) - 1 - output = (12.0+output+50.0*output/(output*output+10.0))/12.0 - 1.0; - if (output > 1.0) { - return 1.0; - } - else if (output < -1.0) { - return -1.0; - } - return output; -} diff --git a/include/cnn1986.h b/include/cnn1986.h deleted file mode 100644 index 3cfde31..0000000 --- a/include/cnn1986.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - This file is part of ct. - - 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 ct. If not, see . -*/ - -#include - -float cnn1986_evaluate_black_win(void); diff --git a/include/negamax.c b/include/negamax.c index 30aed05..e85aba9 100644 --- a/include/negamax.c +++ b/include/negamax.c @@ -1,18 +1,18 @@ /* - This file is part of ct. + This file is part of ct. - 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 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. + 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 ct. If not, see . + You should have received a copy of the GNU General Public License + along with ct. If not, see . */ #include "negamax.h" @@ -31,46 +31,46 @@ static uint64_t negamax_best_action; // =================================================================== static float negamax(const uint8_t cur_depth, const uint8_t init_depth, - float alpha, float beta, - const float colour, const uint64_t hash); + float alpha, float beta, + const float colour, const uint64_t hash); // =================================================================== // Exported functions // =================================================================== void negamax_init(const uint8_t new_board_size) { - board_size = new_board_size; - action_list_init(); - zobrist_init(); - tt_init(); + board_size = new_board_size; + action_list_init(); + zobrist_init(); + tt_init(); } void negamax_free(void) { - zobrist_free(); + zobrist_free(); } float negamax_generate(void) { - // We need to start with something outside of [-∞,∞] because those - // values are wins - const float safe_infty = infty + 1; - float result = -infty; + // We need to start with something outside of [-∞,∞] because those + // values are wins + const float safe_infty = infty + 1; + float result = -infty; - negamax_best_action = -1; + negamax_best_action = -1; - tt_init(); - for (int d = 1; d <= negamax_search_depth; d++) { - result = negamax(d, d, -safe_infty, safe_infty, - (ply & 1) ? +1.0 : -1.0, zobrist_compute()); - } - tt_free(); + tt_init(); + for (int d = 1; d <= negamax_search_depth; d++) { + result = negamax(d, d, -safe_infty, safe_infty, + (ply & 1) ? +1.0 : -1.0, zobrist_compute()); + } + tt_free(); - action_to_ptn(negamax_best_action, negamax_ptn); + action_to_ptn(negamax_best_action, negamax_ptn); - return result; + return result; } // =================================================================== -// α-β negamax with iterative deepening, using the cnn1986 evaluation +// α-β negamax with iterative deepening, using the nn1986 evaluation // function and transposition tables using Zobrist hasing and a // chaining hash table // =================================================================== @@ -79,88 +79,88 @@ static enum TT_FLAG flag; static enum WIN_TYPE w; static float negamax(const uint8_t cur_depth, const uint8_t init_depth, - float alpha, float beta, - const float colour, const uint64_t hash) { - - tt_entry_t *entry = tt_seek(hash); - - // CAUTION: ≥ breaks search stability (vs =) on shallow depths - if (entry != NULL && entry->depth >= cur_depth) { - if (entry->flag == TT_EXACT) { - return entry->value; - } else if (entry->flag == TT_LOWERBOUND && entry->value > alpha) { - alpha = entry->value; - } else if (entry->flag == TT_UPPERBOUND && entry->value < beta) { - beta = entry->value; - } - if (alpha >= beta) return entry->value; - } - - action_list_t *list; - if ((list = action_list_generate()) == NULL) - return alpha; // should never happen! - - if (entry != NULL) { - action_move_to_front(entry->action, list); - } - - if (init_depth > 1 && cur_depth == init_depth) { - action_move_to_front(negamax_best_action, list); - } - - // TODO: what to do if this is never written to? - action_t best_action = list->head->action; - float best_value = -infty; - - for (action_node_t *node=list->head; node!=NULL; node=node->next) { - negamax_display_progress(cur_depth, init_depth, list->length); - - action_take(node->action); - - // Compute the value of the node - float node_value; - if (ply >= 2*board_size - 2 && (w = check_win()) < 0xFF) { - node_value = -colour*infty; - // Check win if far enough into the game - if (w == WIN_ROAD_BLACK || w == WIN_FLAT_BLACK) { - node_value = colour*infty; - } else if (w == WIN_DRAW) { - node_value = 0; - } - } else if (cur_depth > 1) { - // If nobody won, or too early and not leaf, recurse - node_value = -negamax(cur_depth - 1, init_depth, - -beta, -alpha, - -colour, zobrist_compute()); - } else { - node_value = colour * cnn1986_evaluate_black_win(); - } - action_undo(node->action); - - if (node_value > best_value) { - best_value = node_value; - best_action = node->action; - } - - if (best_value > alpha) alpha = best_value; - if (alpha >= beta) break; - } - - action_list_free(list); - if (cur_depth == init_depth) negamax_best_action = best_action; - - flag = TT_EXACT; - if (best_value >= beta) flag = TT_LOWERBOUND; - else if (best_value <= alpha) flag = TT_UPPERBOUND; - - if (entry == NULL) { - tt_insert(hash, flag, cur_depth, best_value, best_action); - } else { - entry->flag = flag; - entry->value = best_value; - entry->depth = cur_depth; - entry->action = best_action; - } - - return best_value; + float alpha, float beta, + const float colour, const uint64_t hash) { + + tt_entry_t *entry = tt_seek(hash); + + // CAUTION: ≥ breaks search stability (vs =) on shallow depths + if (entry != NULL && entry->depth >= cur_depth) { + if (entry->flag == TT_EXACT) { + return entry->value; + } else if (entry->flag == TT_LOWERBOUND && entry->value > alpha) { + alpha = entry->value; + } else if (entry->flag == TT_UPPERBOUND && entry->value < beta) { + beta = entry->value; + } + if (alpha >= beta) return entry->value; + } + + action_list_t *list; + if ((list = action_list_generate()) == NULL) + return alpha; // should never happen! + + if (entry != NULL) { + action_move_to_front(entry->action, list); + } + + if (init_depth > 1 && cur_depth == init_depth) { + action_move_to_front(negamax_best_action, list); + } + + // TODO: what to do if this is never written to? + action_t best_action = list->head->action; + float best_value = -infty; + + for (action_node_t *node=list->head; node!=NULL; node=node->next) { + negamax_display_progress(cur_depth, init_depth, list->length); + + action_take(node->action); + + // Compute the value of the node + float node_value; + if (ply >= 2*board_size - 2 && (w = check_win()) < 0xFF) { + node_value = -colour*infty; + // Check win if far enough into the game + if (w == WIN_ROAD_BLACK || w == WIN_FLAT_BLACK) { + node_value = colour*infty; + } else if (w == WIN_DRAW) { + node_value = 0; + } + } else if (cur_depth > 1) { + // If nobody won, or too early and not leaf, recurse + node_value = -negamax(cur_depth - 1, init_depth, + -beta, -alpha, + -colour, zobrist_compute()); + } else { + node_value = colour * nn1986_evaluate_black_win(); + } + action_undo(node->action); + + if (node_value > best_value) { + best_value = node_value; + best_action = node->action; + } + + if (best_value > alpha) alpha = best_value; + if (alpha >= beta) break; + } + + action_list_free(list); + if (cur_depth == init_depth) negamax_best_action = best_action; + + flag = TT_EXACT; + if (best_value >= beta) flag = TT_LOWERBOUND; + else if (best_value <= alpha) flag = TT_UPPERBOUND; + + if (entry == NULL) { + tt_insert(hash, flag, cur_depth, best_value, best_action); + } else { + entry->flag = flag; + entry->value = best_value; + entry->depth = cur_depth; + entry->action = best_action; + } + + return best_value; } diff --git a/include/negamax.h b/include/negamax.h index 47f4ede..e491baa 100644 --- a/include/negamax.h +++ b/include/negamax.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include @@ -33,8 +33,8 @@ extern char negamax_ptn[9]; extern uint8_t negamax_search_depth; extern void negamax_display_progress(const uint8_t cur_depth, - const uint8_t init_depth, - const uint32_t length); + const uint8_t init_depth, + const uint32_t length); // =================================================================== // Methods diff --git a/include/nn1986.c b/include/nn1986.c new file mode 100644 index 0000000..b9c551c --- /dev/null +++ b/include/nn1986.c @@ -0,0 +1,81 @@ +/* + This file is part of ct. + + 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 ct. If not, see . +*/ + +#include "nn1986.h" +#include "tak.h" +#include "weights.h" + +// =================================================================== +// Implementation of a small neural network +// =================================================================== + +static float cur_board[INP_NUM]; +static float dense1[DENSE_NUM]; +static float output[2]; + +#define RELU(x) ((x) = ((x) < 0) ? 0 : (x)) +float nn1986_evaluate_black_win(void) { + /* --------------- * + * Populate input * + * --------------- */ + for (unsigned int y = 0; y < board_size; y++) { + for (unsigned int x = 0; x < board_size; x++) { + const unsigned int loc = x + y * board_size; + const unsigned int count = COUNT_AT(loc); + float lookup = 0; + if (count > 0) { + if (STONE_AT(loc) == STONE_STANDING) { + lookup = (colours[loc] & 1) ? +0.25 : -0.25; + } else if (STONE_AT(loc) == STONE_CAPSTONE) { + lookup = (colours[loc] & 1) ? +1.00 : -1.00; + } else { + lookup = (colours[loc] & 1) ? +0.50 : -0.50; + } + } + cur_board[3 + loc] = lookup; + } + } + /* ------------------ * + * Convolution layer * + * ------------------ */ + // Add input of flat counts and ply parity + cur_board[0] = (ply & 1) ? 1 : -1; + cur_board[1] = (float)(white_count & 127) / 21.0; + cur_board[2] = (float)(black_count & 127) / 21.0; + /* ------------------ * + * First dense layer * + * ------------------ */ + for (unsigned int d1 = 0; d1 < DENSE_NUM; d1++) { + dense1[d1] = dense1_biases[d1]; + for (unsigned int fl = 0; fl < 3 + 5 * 5; fl++) { + dense1[d1] += cur_board[fl] * dense1_weights[d1][fl]; + } + RELU(dense1[d1]); + } + /* ------------- * + * Output layer * + * ------------- */ + for (uint8_t k = 0; k < 2; k++) { + output[k] = output_bias[k]; + for (unsigned int d2 = 0; d2 < DENSE_NUM; d2++) { + output[k] += dense1[d2] * output_weights[k][d2]; + } + RELU(output[k]); + } + const float norm = output[0] + output[1]; + return (2 * output[0] / norm) - 1; +} diff --git a/include/nn1986.h b/include/nn1986.h new file mode 100644 index 0000000..4e99ac2 --- /dev/null +++ b/include/nn1986.h @@ -0,0 +1,20 @@ +/* + This file is part of ct. + + 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 ct. If not, see . +*/ + +#include + +float nn1986_evaluate_black_win(void); diff --git a/include/weights.c b/include/weights.c index 1aba298..82b55f9 100644 --- a/include/weights.c +++ b/include/weights.c @@ -1,42 +1,33 @@ /* - This file is part of ct. - - 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 ct. If not, see . + * Model: "model" + * _________________________________________________________________ + * Layer (type) Output Shape Param # + * ================================================================= + * input_1 (InputLayer) [(None, 28)] 0 + * + * dense (Dense) (None, 64) 1856 + * + * dense_1 (Dense) (None, 2) 130 + * + * ================================================================= + * Total params: 1,986 + * Trainable params: 1,986 + * Non-trainable params: 0 + * _________________________________________________________________ + * ([0.4593624770641327, 0.8171698451042175], [0.44635653495788574, 0.819940984249115]) */ #include "weights.h" -const 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] = -{-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] = -{{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] = -{-0.559496283531189, -0.1259697526693344, 0.5167818069458008, -0.07613079249858856, 0.016916882246732712, 0.562254011631012, 0.2608274519443512, 0.2632611393928528, 0.019986296072602272, -0.2393009513616562, 0.7170191407203674}; +const float dense1_weights[DENSE_NUM][INP_NUM] = +{{0.09708841890096664, -0.14983339607715607, 0.9531096816062927, 0.14991514384746552, -0.63932865858078, 0.09746148437261581, -0.1670435070991516, 0.25754305720329285, -0.1731426864862442, -0.1653723269701004, -0.3116675615310669, 0.4331771433353424, 0.07788953930139542, -0.3911878764629364, -0.5864945650100708, -0.5138149261474609, -0.10366032272577286, 0.09420160204172134, 0.3116736114025116, -0.8269373774528503, -0.6619208455085754, -1.0483648777008057, -0.05252189561724663, 0.12044219672679901, 0.677895724773407, 0.9947460293769836, -1.109876036643982, -0.20052704215049744}, {0.04853341355919838, -0.44796833395957947, 1.0772864818572998, 0.12211384624242783, 0.43898314237594604, 0.19653372466564178, -0.010857676155865192, -0.34688177704811096, -1.917777180671692, -1.0062774419784546, -0.772797167301178, -0.6764053106307983, -0.15675123035907745, 0.20477063953876495, 0.0170141514390707, 0.0373976044356823, -0.3958517014980316, -0.17130737006664276, 0.10296492278575897, -0.10372677445411682, -0.07705003023147583, -0.21586216986179352, -0.06457874923944473, 0.18130557239055634, -0.19682471454143524, -0.10427158325910568, -0.6213868260383606, 0.2646593451499939}, {0.05100073665380478, -1.490741491317749, 0.5347241759300232, 0.5138917565345764, 0.7368579506874084, -0.3916100859642029, 0.10224276781082153, -0.8944575190544128, 0.9391179084777832, 0.8531733155250549, -0.7068527936935425, -0.1843581348657608, 0.10034217685461044, 0.7256124019622803, -0.5566624402999878, -0.630030632019043, 0.1081201434135437, 0.06458459794521332, -0.06652732193470001, -0.7848819494247437, 0.06676337122917175, 0.19047099351882935, 0.3317343592643738, -1.125041127204895, -0.15809980034828186, 0.7293155193328857, 0.7303928732872009, 0.24778194725513458}, {-0.10748109966516495, 1.3822530508041382, 0.2629156708717346, 0.6968264579772949, 0.17485041916370392, -0.20862552523612976, -0.12484818696975708, -0.23138242959976196, 0.8940210342407227, 0.7281381487846375, 0.2892467975616455, 0.07963291555643082, -0.07487558573484421, -0.1968744993209839, 0.8000355362892151, 0.6640182733535767, 0.22926642000675201, 0.2277926504611969, -0.37833377718925476, -0.2742082476615906, 0.8170139193534851, 0.4202984571456909, 0.27552902698516846, -0.46328070759773254, -0.3581807315349579, 0.10414467751979828, 0.7333625555038452, 0.35470449924468994}, {-0.1888720840215683, 0.9495699405670166, -0.6001124978065491, 0.2289646714925766, 0.1645985096693039, 0.010710741393268108, -0.07195031642913818, -0.3604000210762024, 0.40493911504745483, 0.06439553201198578, -0.1027727797627449, -0.18764203786849976, -0.020061621442437172, 0.41247984766960144, 0.0985364243388176, 0.03292955830693245, 0.13963104784488678, -0.1577671319246292, 0.8160413503646851, 0.3458573818206787, 0.15316851437091827, 0.09699071943759918, -0.15548554062843323, 0.06560410559177399, 0.5002033710479736, 0.6853768825531006, 0.913468599319458, 1.762925148010254}, {-0.05926303192973137, 2.1326680183410645, 0.20786024630069733, 0.20509517192840576, 0.3232854902744293, 0.4138268232345581, 0.23191986978054047, 0.1483074426651001, 0.30143123865127563, 0.36913859844207764, 0.2858075201511383, 0.27123841643333435, 0.21376250684261322, 0.2404519021511078, 0.4652462899684906, 0.23301848769187927, 0.3275870382785797, 0.3245834708213806, 0.35785531997680664, 0.21870960295200348, 0.28119996190071106, 0.385022908449173, 0.2985413074493408, 0.015570216812193394, 0.2387431263923645, 0.3773896098136902, 0.3013421595096588, 0.09287303686141968}, {-0.13003307580947876, 1.7538926601409912, -0.6812999844551086, -0.4881831109523773, -0.4694475829601288, 0.75823974609375, 0.2842443883419037, 0.31535980105400085, -0.4027916193008423, 0.6403568387031555, 0.7254506945610046, 0.31957608461380005, 0.6868956089019775, 0.6129562854766846, 0.6620163917541504, -0.19040672481060028, 0.2591014504432678, 0.17981182038784027, 0.3206057548522949, 0.26464489102363586, 0.12509778141975403, -0.1723550260066986, 0.5769479274749756, 0.27363383769989014, 0.40419286489486694, 0.4196736216545105, 0.474353551864624, 0.3851746618747711}, {0.004320172592997551, -0.06554269790649414, 1.0545583963394165, 0.03816256299614906, -0.3641563057899475, -0.04311445355415344, -1.0777692794799805, 0.3634617328643799, -0.2762683629989624, 0.2931346595287323, 0.12660370767116547, -0.8033497333526611, -0.08709059655666351, 0.2099713832139969, 0.38327884674072266, 0.11443039029836655, -0.8581308722496033, -0.6271834969520569, 0.01899813674390316, -0.36976635456085205, -0.9609361290931702, -1.242712140083313, -0.20354503393173218, -0.892693042755127, -1.3654234409332275, -0.1457122266292572, 0.4198227822780609, 0.47160959243774414}, {-0.1309877187013626, 1.7283211946487427, -0.34542015194892883, 0.09756244719028473, 0.10365703701972961, 0.16427665948867798, 0.5429031848907471, 0.000730195315554738, 0.9568342566490173, 0.43416130542755127, 0.5171336531639099, -0.03411416709423065, 0.09991542249917984, 0.22394727170467377, 0.46084511280059814, 0.2941528856754303, 0.40269896388053894, 0.4282401502132416, -0.043696314096450806, 0.9397956728935242, 0.4523789584636688, 0.21760058403015137, 0.25844889879226685, -0.0975789725780487, 1.4064749479293823, -0.4462650716304779, -0.0176702868193388, -0.15949156880378723}, {-0.09322677552700043, 1.4953668117523193, -0.6572163701057434, 0.03580909222364426, 0.07035914063453674, 1.2231422662734985, 0.14995643496513367, -0.01055422704666853, -0.3619900643825531, 0.00962253101170063, 1.1480656862258911, 0.04119277000427246, -0.029596557840704918, -0.20450031757354736, -0.20949582755565643, 1.3544684648513794, -0.07676524668931961, -0.33410149812698364, 0.14368489384651184, 0.18317444622516632, 0.9521495699882507, 0.2047186642885208, -0.14690256118774414, -0.002987049985677004, 0.22252139449119568, 0.5207418203353882, 0.3862583041191101, 0.04728662222623825}, {0.12120318412780762, -0.32054218649864197, 0.2999326288700104, 0.914248526096344, -0.25369349122047424, 1.0056365728378296, 1.0900052785873413, -1.9740498065948486, -0.2208552062511444, 0.12854935228824615, 0.17538198828697205, -0.1234835833311081, -1.1125203371047974, -0.3354377746582031, -0.5196758508682251, -0.30077362060546875, -0.5856597423553467, -0.8402205109596252, -0.22239884734153748, -0.4105615019798279, -0.38801825046539307, -0.8613605499267578, -0.27762359380722046, 0.49667125940322876, 0.020931968465447426, -0.12382236868143082, -0.4301914572715759, -0.350443035364151}, {-0.07766333967447281, 0.6034705638885498, -4.554388523101807, 0.2126956582069397, 0.15929296612739563, 0.17145121097564697, 0.1601206660270691, 0.17433294653892517, 0.12817388772964478, 0.11653872579336166, 0.14781475067138672, 0.23677119612693787, 0.12034492939710617, 0.1955379694700241, 0.13016147911548615, 0.23828306794166565, 0.14038963615894318, 0.15755616128444672, 0.23868830502033234, 0.26690152287483215, 0.1843731850385666, 0.17341510951519012, 0.057188548147678375, 0.2539713680744171, 0.2696954309940338, 0.18604490160942078, 0.14197516441345215, 0.36821600794792175}, {0.15129533410072327, 0.09887662529945374, 1.2054975032806396, 0.24753500521183014, 0.4909513294696808, -1.6100319623947144, 0.07008431106805801, 0.1423417031764984, -0.09243771433830261, -0.34568139910697937, -1.0303078889846802, 0.18709783256053925, 0.6571977138519287, -0.11068439483642578, -0.14676885306835175, -0.6726709008216858, -0.6291938424110413, 0.6409110426902771, -0.4643811285495758, -0.06342993676662445, -0.3956544101238251, -0.7433932423591614, -1.4594924449920654, -0.2231053113937378, -0.31123557686805725, 0.03604980930685997, -0.01676316000521183, -0.010373279452323914}, {0.08248379826545715, -0.33374691009521484, 0.4519060552120209, -0.3651171028614044, -1.0735950469970703, 0.005808517802506685, 1.2023851871490479, 0.7546958327293396, -0.19511595368385315, -0.5970048904418945, -1.1051145792007446, -0.513593316078186, 1.0888173580169678, 0.2880654036998749, 0.14094868302345276, -0.5696795582771301, -1.0076549053192139, 0.19139567017555237, 0.336557537317276, 0.3891679644584656, 0.09406869858503342, -0.8800191283226013, -0.5774187445640564, 0.18142414093017578, 0.17849640548229218, -0.11618805676698685, -0.6260532736778259, -0.39390552043914795}, {-0.07623733580112457, 1.0555744171142578, -0.17468947172164917, 0.18221747875213623, 0.06131114810705185, -0.014457565732300282, 0.1536666601896286, 0.6676269769668579, 0.17481842637062073, -0.14446255564689636, 0.04878826066851616, 0.27363839745521545, 0.5058372020721436, 0.16395719349384308, 0.19522777199745178, 0.31879734992980957, 0.8337258696556091, 0.612602710723877, 0.18271851539611816, 0.12550194561481476, 0.7062245011329651, 0.2406325489282608, -0.5638207793235779, 0.44285738468170166, 0.49697133898735046, 0.655937135219574, -0.5988529324531555, -0.6180514693260193}, {-0.08515164256095886, 1.8156886100769043, -0.3055272698402405, -0.00542338564991951, 0.28451383113861084, 0.3305817246437073, 0.44789642095565796, 0.007520807906985283, 0.6411338448524475, 0.6627947688102722, 0.3936305642127991, 0.543207585811615, 0.31023091077804565, 0.5907645225524902, -0.5054730772972107, 0.5622344613075256, 0.46472644805908203, 0.7537768483161926, 0.5771557092666626, 0.6231046915054321, 0.5562911629676819, 0.05025006830692291, 0.4974210858345032, -0.021163247525691986, 0.428413450717926, 0.2096228450536728, 0.1297932267189026, 0.15994444489479065}, {0.059478625655174255, -1.2593594789505005, 0.8060709238052368, -0.5756357312202454, -0.5642467141151428, -1.1023842096328735, -1.0840095281600952, -1.7373161315917969, 0.051716454327106476, -0.18114325404167175, 0.03431779146194458, 0.07772735506296158, 0.30920106172561646, 0.06860094517469406, 0.053684305399656296, 0.050935737788677216, 1.5831908967811614e-05, 0.06146225333213806, 0.14663179218769073, 0.01896907575428486, -0.017615582793951035, 0.049037203192710876, 0.3536975681781769, 0.5997693538665771, 0.06265199184417725, 0.018393227830529213, -0.03553879261016846, 0.15440478920936584}, {-0.06590350717306137, 0.6541862487792969, -0.9594393968582153, 1.5689195394515991, 0.995005190372467, 0.7445554733276367, 0.92704838514328, 0.4702519476413727, -0.3339536786079407, -0.18121398985385895, 0.12824110686779022, 0.32404643297195435, 0.08692658692598343, 0.06525395065546036, -0.07403562217950821, -0.08786602318286896, 0.30545052886009216, 0.1610720455646515, 0.025930603966116905, -0.006452936679124832, 0.04217161983251572, -0.00885680504143238, 0.01933605782687664, -0.5424081683158875, 0.03653205558657646, -0.09611544758081436, 0.07054111361503601, -0.33712488412857056}, {-0.033981095999479294, 0.7148251533508301, -0.9412906169891357, -0.14343379437923431, -0.10766273736953735, -0.11414168775081635, -0.13219089806079865, 1.2587040662765503, 0.008397090248763561, -0.10059479624032974, 0.13039082288742065, 0.12154032289981842, 1.238200306892395, -0.19973790645599365, -0.05784938111901283, 0.017947781831026077, -0.04616774618625641, 1.1192306280136108, 0.07938524335622787, -0.005415983498096466, 0.09550166130065918, 0.09772814065217972, 1.2091776132583618, -0.30785369873046875, -0.05821114033460617, -0.06727229803800583, -0.04389581456780434, 1.2299752235412598}, {0.1273789405822754, -0.341524600982666, 1.151167392730713, -0.04134071618318558, -0.07647605985403061, 0.36836978793144226, -1.3937312364578247, -0.16971394419670105, -0.1672888547182083, 0.05098025128245354, 0.4777861535549164, -1.6180260181427002, -0.14700591564178467, -0.42429643869400024, -0.571417510509491, -0.3194080591201782, -1.2477779388427734, 0.7285082340240479, -0.5621447563171387, -0.067803755402565, -0.33690130710601807, -1.2182284593582153, -0.026820745319128036, 0.24996322393417358, -0.04271029680967331, -0.25508779287338257, -0.18486416339874268, -0.2532777190208435}, {0.11533160507678986, 0.3406147062778473, 1.8792569637298584, 0.018996711820364, -0.2056526243686676, -0.33621448278427124, -0.20685425400733948, -0.24743612110614777, -0.17051126062870026, -0.584708034992218, -0.40372198820114136, -0.37256744503974915, -0.34893912076950073, -0.3406921923160553, -0.5737095475196838, 0.9329007267951965, -0.5134408473968506, -0.3319478929042816, -0.1288238763809204, -0.5994487404823303, -0.5022518038749695, -0.49213001132011414, -0.13361960649490356, -0.02503959834575653, -0.33584609627723694, -0.30276021361351013, -0.16746489703655243, 0.13810385763645172}, {-0.09611523896455765, 1.238119125366211, -0.4888734817504883, 0.20628002285957336, 0.37660905718803406, 0.22086504101753235, 1.418500542640686, -0.3454299569129944, 0.2719173729419708, 0.19811256229877472, 0.3238287568092346, 1.0737624168395996, -0.12214085459709167, 0.3549494743347168, 0.2717260420322418, -0.009705607779324055, 0.853428304195404, 0.24796196818351746, 0.33442437648773193, -0.13321736454963684, 0.13895970582962036, 0.3937171995639801, 0.6743841767311096, -0.2558365762233734, 0.33873921632766724, -0.2011198103427887, -0.24151191115379333, 1.0191739797592163}, {0.028014613315463066, -0.4389137625694275, 1.2217202186584473, 0.5615558624267578, 0.05263078957796097, 0.05092257261276245, -0.0025020919274538755, -0.10499066114425659, 0.22626706957817078, -0.18914547562599182, 0.04754278063774109, 0.03034340962767601, -0.22401578724384308, -1.2998645305633545, -0.9751662015914917, -0.7423930764198303, -0.3970774710178375, -0.061214447021484375, -0.08540238440036774, 0.45488816499710083, -0.14393432438373566, -0.23829105496406555, -0.26323971152305603, 0.2596847116947174, 0.37555330991744995, 0.11025014519691467, -0.4083321690559387, 0.15121963620185852}, {-0.21241767704486847, 1.6689105033874512, -0.226408913731575, 0.03731200098991394, 0.26310592889785767, 1.2660009860992432, -0.47913163900375366, -0.4116690158843994, 0.39553773403167725, 0.0419420562684536, 1.0190608501434326, 0.3955974280834198, -0.2669771909713745, 0.22511376440525055, 0.19040349125862122, 0.3689280152320862, 0.5754274725914001, 0.791631281375885, 0.17811143398284912, 0.364437997341156, 0.13787342607975006, 0.1953200399875641, 0.35008370876312256, 0.40746477246284485, 0.021115917712450027, 0.19234441220760345, 0.34583356976509094, 0.221570685505867}, {-0.056629478931427, 1.3422456979751587, -0.48497992753982544, -0.1941925585269928, 0.165594220161438, 0.287276953458786, 0.15132613480091095, 0.38584816455841064, 0.2143339067697525, 0.13520006835460663, 0.2816779315471649, 0.36108213663101196, 0.5532099604606628, 0.2023126780986786, 0.26956668496131897, 0.06489624828100204, 0.8025456070899963, 0.01022995077073574, 0.20568951964378357, 0.3348022401332855, 0.235650435090065, 1.00911283493042, -0.1623430848121643, -0.029755957424640656, 0.16051626205444336, -0.30153003334999084, 1.820574402809143, -0.18349412083625793}, {0.08210670948028564, -0.10644663870334625, 2.0925099849700928, -0.24863389134407043, -0.2665429711341858, -0.40262511372566223, -0.45371878147125244, -0.1377442479133606, -0.39157360792160034, -0.22115609049797058, -0.4804888963699341, -0.2904321551322937, -0.18321593105793, -0.33899354934692383, -0.3302883207798004, -0.2938438951969147, -0.18833966553211212, -0.30292198061943054, -0.35079896450042725, -0.2308332324028015, -0.343620240688324, -0.29516926407814026, -0.2986883819103241, -0.16443338990211487, -0.44009503722190857, -0.27044206857681274, -0.4302333891391754, -0.036748480051755905}, {-0.020061643794178963, 1.2271647453308105, -0.7192057967185974, 0.22154885530471802, -0.2719059884548187, 0.45283734798431396, 0.23891234397888184, 0.06230388209223747, -0.3005612790584564, 0.38583460450172424, 0.09369464963674545, 0.25240558385849, 0.22129446268081665, -0.14313091337680817, -0.03104626201093197, 0.07079270482063293, 0.4938150942325592, 0.4324195086956024, 1.1018677949905396, 1.2313228845596313, 0.8778300881385803, 1.1587250232696533, 0.23411384224891663, -0.05438053980469704, -0.20136210322380066, -0.25242170691490173, 0.27750808000564575, 0.13955263793468475}, {0.21351471543312073, 0.13765887916088104, 2.0183377265930176, -0.007917194627225399, -0.3589908182621002, -0.5994181036949158, -0.11847121268510818, 0.021346328780055046, -0.4103794991970062, -0.41012945771217346, 0.18445296585559845, -0.6636074185371399, -0.24117298424243927, -0.3390832841396332, -0.40450406074523926, -0.3359193205833435, -0.39004817605018616, -0.2984693646430969, -0.22267311811447144, -0.3200683295726776, -0.17157769203186035, -0.15781398117542267, -0.20106711983680725, -0.3199653625488281, -0.28912240266799927, -0.5469598174095154, -0.598488450050354, -0.20015941560268402}, {0.13156303763389587, -0.04746222496032715, 1.4406293630599976, 0.04010009765625, -0.19504183530807495, -0.3422450125217438, -0.30269885063171387, 0.03397633880376816, -0.34146347641944885, -0.2657840847969055, -0.5875772833824158, -0.3439021110534668, -0.24916069209575653, -0.06749272346496582, -0.6978026032447815, -0.5449330806732178, -0.6765002608299255, -0.374035120010376, -0.0997399315237999, -0.7321766018867493, 0.932058572769165, -0.7302301526069641, -0.10420955717563629, 0.09721499681472778, -0.7511874437332153, -0.5356468558311462, -0.7049369215965271, 0.10399650782346725}, {-0.026832129806280136, 0.9518526792526245, 0.027437914162874222, 0.03834706172347069, 0.19063116610050201, 0.06822194904088974, 0.025699865072965622, -0.0034538416657596827, 0.5062559247016907, 0.48999106884002686, 0.839417040348053, 1.0514994859695435, -0.33073392510414124, 0.4111200273036957, -0.09617988020181656, -0.6156681776046753, 0.7947877049446106, 0.5059559345245361, 0.3703654408454895, -0.01992918737232685, 0.010815472342073917, 0.7090519666671753, 0.33787572383880615, 0.3802514672279358, 0.27450019121170044, 0.7134937047958374, 0.47950777411460876, 0.07987868040800095}, {-0.12225848436355591, 1.7318753004074097, -0.2236385941505432, 0.164175882935524, 0.6606665253639221, -0.09252867102622986, -0.09040944278240204, -0.01922728307545185, 0.2076280564069748, 0.5997986793518066, 0.8389816284179688, 1.0328935384750366, 1.4117224216461182, 0.2752927839756012, 0.3150433599948883, 0.3206954002380371, 0.3793025016784668, -0.2018655240535736, 0.1428735852241516, 0.4109397232532501, 0.2945535182952881, 0.2752903401851654, 0.1045895516872406, -0.013057844713330269, 0.33169877529144287, 0.5139592885971069, 0.06500981748104095, -0.03201531246304512}, {0.037458743900060654, -0.0013948864070698619, 1.5822151899337769, 0.2050805389881134, -0.1646299958229065, -0.19420349597930908, -0.09858932346105576, 0.03837038576602936, -0.14196360111236572, -0.5955793857574463, -0.6105048656463623, -0.19990204274654388, -0.14786484837532043, -0.4259253144264221, 1.1276053190231323, -0.5819753408432007, -0.5576790571212769, -0.37708580493927, -0.4070882201194763, -0.5314394235610962, -0.6408591866493225, -0.3505810797214508, 0.024513090029358864, 0.16252656280994415, -0.3316267132759094, -0.22024187445640564, -0.29375335574150085, -0.08565379679203033}, {-0.0819413959980011, 1.0591763257980347, -0.7337607741355896, -0.17952848970890045, 0.8200972676277161, 0.8254687190055847, 0.8399497866630554, 1.0778814554214478, 0.32117852568626404, 0.6869990229606628, 0.4733969271183014, 0.19321654736995697, -0.2765744924545288, 0.39945876598358154, 0.6774672269821167, 0.09932424128055573, -0.20062103867530823, -0.2712205648422241, 0.7035691142082214, 0.20941823720932007, -0.1504993587732315, 0.1819196194410324, 0.0758715346455574, 0.9624840021133423, -0.10010877996683121, 0.047227196395397186, 0.07651358097791672, -0.15292885899543762}, {-0.03150544688105583, -0.02839292772114277, -0.5884301662445068, 0.039681024849414825, 0.08184020221233368, 0.10623382031917572, 0.009769861586391926, -0.07766010612249374, -0.021818384528160095, 0.2412724792957306, 0.11478745937347412, 0.05257875472307205, 0.07520901411771774, 0.05953354015946388, 0.22793656587600708, 0.12766006588935852, 0.15545566380023956, 0.09512616693973541, 0.1359385848045349, 0.2246624231338501, 0.1218600645661354, 0.13645589351654053, 0.022114301100373268, -0.0938657894730568, 0.053409822285175323, 0.04353907331824303, 0.05621011555194855, 0.024152453988790512}, {-0.10731056332588196, 1.9101223945617676, -0.14491631090641022, -0.31954917311668396, -0.13067302107810974, -0.38983073830604553, 1.2752583026885986, 0.10712035745382309, -0.02182578109204769, -0.27314284443855286, 0.5775480270385742, 0.8474040031433105, 0.3230977952480316, -0.09060269594192505, 0.5151476263999939, 0.8193845152854919, 0.4053916931152344, 0.2335839718580246, 1.1781198978424072, 0.8876485228538513, 0.494328111410141, 0.10951576381921768, 0.35883137583732605, 0.031916506588459015, 0.24021664261817932, 0.4334607720375061, 0.32361146807670593, 0.12500637769699097}, {-0.048089589923620224, 0.2517174184322357, -0.6230883598327637, 0.03189172223210335, 0.028296470642089844, 0.05605744197964668, 0.08526457846164703, 0.05624855309724808, 0.04614025354385376, 0.0461905337870121, 0.07688868790864944, 0.1092841625213623, 0.06774014234542847, -0.03262807056307793, 0.08905143290758133, 0.0877608135342598, 0.06686928868293762, 0.07233935594558716, 0.057617634534835815, 0.016904741525650024, 0.04663266986608505, 0.07950703799724579, 0.00545073114335537, 0.07434149831533432, 0.03768325597047806, 0.10711461305618286, 0.06703071296215057, 0.10979264229536057}, {-0.08404885232448578, -0.7368913888931274, 0.4573487937450409, 0.13284821808338165, 0.3613227605819702, 0.14185453951358795, 0.6336719393730164, -1.4996527433395386, 0.14475664496421814, 0.29121872782707214, 0.4278671443462372, 0.1410083919763565, -0.8940686583518982, 0.2855665683746338, 0.42577508091926575, 0.32199257612228394, -0.29421567916870117, -0.47793734073638916, 0.3777045011520386, 0.19965225458145142, -0.2553655505180359, -0.7715121507644653, -0.7749602794647217, -0.9258174300193787, -0.47367092967033386, -0.7522175312042236, -0.6750305891036987, -0.22101743519306183}, {0.14481350779533386, -0.008970635011792183, 1.508664608001709, 0.15015840530395508, -0.14811588823795319, 0.588955819606781, -1.0150330066680908, -0.053266044706106186, 0.07046253234148026, -1.5722743272781372, -1.0555866956710815, -1.0166481733322144, -0.24272829294204712, -0.41724616289138794, -0.8357856273651123, -0.03276902064681053, -0.04676911234855652, -0.26494157314300537, -0.4370666444301605, -0.7593159079551697, -0.053759537637233734, 0.3186907172203064, -0.5872452855110168, 0.03758898749947548, -0.4328208863735199, -0.21179579198360443, -0.40803515911102295, 0.0951615571975708}, {0.00908249244093895, -0.07688987255096436, 0.782505452632904, 0.06486380100250244, -0.2471565157175064, 0.021011406555771828, 0.022204816341400146, 0.1792861968278885, -0.13489873707294464, -0.036091145128011703, -0.43057775497436523, -0.031296003609895706, -0.2873421311378479, 0.22351358830928802, -0.026948416605591774, -0.8745213150978088, 0.11529920995235443, 0.24653159081935883, 0.5388697981834412, 0.47889870405197144, -1.1142454147338867, 0.3187515139579773, 0.38350510597229004, 0.02950381115078926, 0.29876217246055603, -2.0111100673675537, 0.5463553071022034, 0.14435721933841705}, {0.14901532232761383, -1.5044587850570679, 0.8972142338752747, 0.2778427302837372, -0.05853148549795151, 0.1994359791278839, -0.30804818868637085, -0.2415803223848343, -0.22669333219528198, -0.09136048704385757, -0.09575177729129791, -0.5684528946876526, -0.5545351505279541, 0.11623877286911011, -0.16263911128044128, -0.040955785661935806, -0.049217116087675095, -0.8552798628807068, -0.048276450484991074, 0.10525430738925934, 0.33164283633232117, 0.24776573479175568, -0.9200206398963928, 0.14236557483673096, -0.1810273379087448, 0.08166225254535675, 0.7190329432487488, -2.1177501678466797}, {-0.19271403551101685, 1.728354811668396, -0.49745607376098633, 0.13163147866725922, 0.4125182628631592, 0.3173934519290924, 0.3347082734107971, 0.1567714363336563, 0.44411492347717285, 0.5317234992980957, -0.5201308727264404, 0.5674026012420654, 0.41059064865112305, 0.49735933542251587, 0.624692440032959, 0.854070246219635, 0.6220293045043945, 0.3193413019180298, 0.22398653626441956, 0.40847501158714294, 0.5839058756828308, 0.1582852154970169, 0.33516645431518555, 0.03460458666086197, 0.4448821544647217, 0.8498842120170593, 0.3459503650665283, 0.11562537401914597}, {-0.047379519790410995, 1.703660488128662, -0.5990813374519348, -0.5269250273704529, 1.5372254848480225, -0.2775944471359253, 0.001394903170876205, -0.19458095729351044, -0.27556341886520386, 0.9208241105079651, 0.21152672171592712, 0.06251904368400574, 0.2743033468723297, 0.06462933868169785, 0.7903530597686768, 0.39518019556999207, 0.31461477279663086, 0.7033582925796509, 1.100284457206726, 0.583648681640625, 0.5865142941474915, -0.006218436639755964, 0.31119057536125183, 0.5512746572494507, 0.037552036345005035, -0.026546820998191833, 0.3478201627731323, 0.03815087676048279}, {0.028824783861637115, -0.32616135478019714, 1.2353787422180176, -0.4744008779525757, -1.8294140100479126, -0.17039445042610168, -0.16263258457183838, -0.27589941024780273, 0.02396584302186966, -0.6765327453613281, 0.026453670114278793, -0.20710843801498413, 0.12056914716959, -0.027168219909071922, -0.472407728433609, -0.06178409606218338, -0.02956007793545723, -0.03951815888285637, -0.16745562851428986, -0.19822148978710175, -0.06916672736406326, 0.018468298017978668, -0.5161017179489136, -0.3942733108997345, -0.036136265844106674, -0.22772735357284546, -0.1378902643918991, 0.15064162015914917}, {0.03982025757431984, -2.4930081367492676, 0.8281068801879883, -0.4357646107673645, 0.10274703055620193, -0.665107786655426, 0.5115349888801575, 0.32747960090637207, -0.09119489789009094, 0.2945898175239563, -0.1673634648323059, -0.6479430794715881, 0.1562136858701706, -1.237152338027954, -0.3490593731403351, 0.027165303006768227, -0.03953339904546738, -0.7550083994865417, 0.424204021692276, -0.8311765193939209, -0.3301525413990021, -0.052060894668102264, 0.24890226125717163, 0.5295188426971436, 0.2250201553106308, -0.709912896156311, 0.1652745008468628, 0.02529488131403923}, {0.030456073582172394, -0.5592262744903564, 1.432510256767273, -1.1988471746444702, -0.5064346194267273, -0.6237148642539978, 0.40195557475090027, 0.25146642327308655, 0.5024128556251526, -0.12030938267707825, -0.7599889039993286, -1.1147559881210327, -1.3214906454086304, 0.37952062487602234, 0.0130626754835248, -0.057461678981781006, -0.4395413398742676, -0.39032915234565735, -0.04154334217309952, 0.3974667191505432, -0.22250966727733612, -0.495175838470459, 0.04570012539625168, 0.31906959414482117, -0.14886492490768433, 0.3113555312156677, -0.6547025442123413, 0.08879609405994415}, {0.11950501054525375, -0.48032498359680176, 1.2850854396820068, 0.06694980710744858, -0.16385744512081146, -0.3026943802833557, -0.25026676058769226, 0.08888517320156097, 0.06509137898683548, -0.17576169967651367, -0.06554707139730453, -0.08778101950883865, -0.30888912081718445, 0.06313688308000565, -0.03595643863081932, -0.1171422153711319, -0.13362252712249756, -0.10691016912460327, -2.0260233879089355, -0.8719305992126465, -0.5115545392036438, -0.20826612412929535, 0.0837148055434227, -0.10446202009916306, 0.4123838543891907, -0.08748969435691833, -0.28654301166534424, -0.22568418085575104}, {-0.0004980643279850483, 1.6956111192703247, -0.9341049194335938, 0.3910086750984192, 0.9375659823417664, -0.599976658821106, -0.1314917951822281, -0.2129734605550766, 0.21699850261211395, 1.0505825281143188, 0.901665449142456, -0.0852508544921875, -0.17882975935935974, 0.2928134500980377, -0.2693397104740143, 0.8399291038513184, 0.6454485654830933, 0.3374834358692169, 0.04004263877868652, 0.24971531331539154, -0.05535968020558357, 0.7141254544258118, 0.5550016760826111, -0.20664328336715698, 0.16429021954536438, 0.6384597420692444, 0.4723033607006073, -0.08882896602153778}, {-0.14170923829078674, 1.3551650047302246, -0.9581169486045837, 0.9161777496337891, 0.030683813616633415, 0.2503061294555664, 0.07654116302728653, -0.013592132367193699, 0.4500807523727417, 0.961696445941925, 0.3948116898536682, 0.7503361105918884, 0.32386764883995056, -0.4451524317264557, 1.040030598640442, -0.16870202124118805, -0.37502360343933105, 0.5298779606819153, -0.11141359061002731, 1.0228924751281738, -0.31592369079589844, -0.04017551988363266, -0.15074723958969116, 0.0482744537293911, 1.1439263820648193, 0.4571666717529297, 0.12239103764295578, 0.4535315930843353}, {-0.032109931111335754, -0.12122310698032379, 0.8914746642112732, -0.27882638573646545, -0.11921525001525879, 0.32706254720687866, 0.2490244358778, 0.3580411672592163, -0.2604867219924927, -0.21825937926769257, -0.012418774887919426, 0.19902339577674866, 0.2708764672279358, 0.2748216688632965, -0.3405546247959137, -0.8040348291397095, -0.9789102077484131, -1.7298134565353394, -0.25523945689201355, -0.07197760790586472, -0.021183472126722336, 0.24487651884555817, 0.5359469652175903, -0.04558420553803444, -0.1392718106508255, 0.26097846031188965, 0.41951051354408264, 0.2396070510149002}, {-0.1434144526720047, 1.5024970769882202, -0.26019152998924255, -0.032202448695898056, 0.32650431990623474, 0.39354056119918823, 0.19199824333190918, 0.15139684081077576, 0.2088635414838791, 0.23116657137870789, 0.34120866656303406, 0.2512649595737457, 0.04610608145594597, 0.45557311177253723, 0.46523430943489075, 0.3187943994998932, 0.25996607542037964, -0.3529891073703766, 0.18252035975456238, 0.43683773279190063, 0.8012835383415222, 1.1804018020629883, 1.7978644371032715, 0.37052586674690247, 0.6495969295501709, 0.21544672548770905, -0.24423786997795105, -0.04839114099740982}, {0.08772090822458267, 0.036836814135313034, 0.4411259591579437, -0.2324865311384201, -0.4422452747821808, 0.3720940351486206, 0.0609813816845417, 0.4158213138580322, -0.6237788200378418, -1.4070799350738525, 1.0921244621276855, 0.4683806300163269, -0.1926126927137375, 0.5655200481414795, -1.2423927783966064, -0.6283270120620728, -0.5818661451339722, 0.1723531186580658, 0.5311585068702698, -0.6664415597915649, -0.42718756198883057, -0.5389712452888489, -0.5409123301506042, -0.19837777316570282, -0.42452719807624817, -0.42125552892684937, 0.2389526516199112, 0.04127349331974983}, {0.13081054389476776, -0.11356072872877121, 1.4752963781356812, -0.07947410643100739, -0.2676275968551636, -0.3330131471157074, -0.20006857812404633, -0.04646018147468567, -0.4903687834739685, -0.45940980315208435, -0.631168782711029, -0.4270765483379364, -0.3620588183403015, -0.27580520510673523, -0.44114959239959717, -0.7304320335388184, 0.9806434512138367, -0.47282716631889343, -0.19448859989643097, -0.6225467920303345, -1.0841974020004272, -0.738459587097168, -0.8378979563713074, -0.14952285587787628, -0.2907923758029938, -0.20345616340637207, -0.3887461721897125, 0.09503486752510071}, {-0.06538720428943634, 0.7628426551818848, -0.48973286151885986, -0.38497161865234375, 0.15466463565826416, 0.11393487453460693, 0.030808981508016586, -0.3597305119037628, 0.03768155723810196, 0.024493861943483353, 0.04951104521751404, 0.14642468094825745, 0.07216943800449371, -0.12633569538593292, 0.016758088022470474, 0.13920584321022034, 0.13626915216445923, 0.07511813938617706, -0.2962007224559784, -0.1386595219373703, 0.2720275819301605, 0.21500355005264282, 0.6123909950256348, 1.9834942817687988, 0.9948948621749878, 0.9978277683258057, 0.8778850436210632, 0.6260098218917847}, {-0.16871626675128937, 1.4061483144760132, -0.5023764371871948, 0.33703121542930603, 0.8559048771858215, 0.469501256942749, 0.7470555305480957, 0.30814874172210693, 0.564860999584198, 0.40895015001296997, 0.10864124447107315, 0.1458897590637207, 0.3857732117176056, 0.7911720871925354, 0.7119686603546143, -0.250042200088501, 0.17346656322479248, 0.3537016212940216, -0.41765081882476807, 1.0786654949188232, 0.8970625996589661, 0.5761362910270691, 0.5433169603347778, -0.6643967032432556, -0.48398444056510925, 1.2207279205322266, 0.514649510383606, 0.21612684428691864}, {-0.08570192009210587, 1.214324712753296, -0.13377290964126587, 0.34323278069496155, -0.14258965849876404, -0.18832489848136902, -0.08113601058721542, -0.029942357912659645, 0.0971248522400856, 0.11952006071805954, 0.09883774071931839, 0.2491564154624939, 0.07593998312950134, 1.131385087966919, 1.2205246686935425, 1.1922342777252197, 1.2262190580368042, 0.48976269364356995, 0.22512586414813995, 0.33211636543273926, -0.5047371983528137, 0.2883317172527313, 0.23470860719680786, 0.24038122594356537, -0.04741585999727249, -0.5512517094612122, -0.08958519995212555, 0.3993839919567108}, {-0.09156186878681183, 1.447799801826477, -0.8677529096603394, -0.2403821051120758, -0.24082186818122864, 0.09531288594007492, 1.1842302083969116, 0.7055855393409729, 1.238553762435913, 0.830436646938324, 0.7400990724563599, 0.5128685832023621, -0.1964624524116516, -0.3230336308479309, -0.12294219434261322, 0.24010124802589417, 0.3363843262195587, -0.19299542903900146, -0.1038021519780159, 0.10120601207017899, 0.30215927958488464, 0.0030945949256420135, 0.162748321890831, 0.048576682806015015, 0.3265083134174347, 0.43292054533958435, 0.1647973358631134, -0.14344830811023712}, {-0.14595773816108704, 2.036177635192871, -0.15678788721561432, -0.19012169539928436, 0.042336251586675644, 0.09402280300855637, 0.7207157611846924, 0.14010852575302124, 0.013773145154118538, 0.2021285742521286, 0.8130205273628235, 0.697592556476593, 0.19569545984268188, 1.3054842948913574, 0.7752094864845276, 0.8463451862335205, -0.43331101536750793, 0.39584746956825256, -0.026438673958182335, 0.35300928354263306, 0.6822341680526733, 0.5199337005615234, 0.4171527326107025, -0.19292718172073364, 0.30702468752861023, 0.2383618950843811, 0.49791133403778076, 0.2006896585226059}, {-0.016399526968598366, -0.8661689162254333, 0.627953827381134, 0.8040047883987427, 0.2690049409866333, -0.05720654875040054, 0.20661626756191254, 0.49369704723358154, 0.1373131424188614, -0.08826663345098495, -0.16605296730995178, 0.23632067441940308, -0.04646783322095871, 0.3226010203361511, -0.21266025304794312, 0.13406658172607422, 0.3166760206222534, 0.39453834295272827, 0.22649653255939484, -0.2949632406234741, -0.30884310603141785, 0.1574787050485611, 0.8918634653091431, -0.6566658616065979, -1.055477261543274, -0.9904500842094421, -1.3658781051635742, -1.9980671405792236}, {0.12702903151512146, -4.264755725860596, 0.1351483166217804, -0.20723043382167816, -0.2467646598815918, -0.13731075823307037, -0.2164659947156906, -0.14355270564556122, -0.14075502753257751, -0.25379636883735657, -0.17323608696460724, -0.1511029303073883, -0.17861734330654144, -0.15422824025154114, -0.07887014746665955, -0.16572877764701843, -0.1545283943414688, -0.18726830184459686, -0.1911981999874115, -0.22419621050357819, -0.14734145998954773, -0.1506907343864441, -0.26516038179397583, -0.17076921463012695, -0.20366378128528595, -0.2068306803703308, -0.2465706467628479, -0.07892344892024994}, {0.08080519735813141, 0.1585157960653305, 1.8969849348068237, -0.20419242978096008, -0.2912924289703369, -0.36874666810035706, -0.40501853823661804, -0.19646884500980377, -0.142297625541687, -0.22064056992530823, -0.3288157284259796, -0.32355132699012756, -0.5395388007164001, -0.5318061709403992, -0.3192610740661621, -0.27381959557533264, -0.34684738516807556, -0.5140829086303711, -0.373310923576355, -0.413587361574173, -0.2374996393918991, -0.21946990489959717, -0.3940057158470154, -0.18182581663131714, -0.3221309185028076, -0.45614495873451233, -0.12116502225399017, -0.17031502723693848}, {0.07794322818517685, -0.10273882746696472, 1.2109743356704712, 0.018595527857542038, 0.056782107800245285, -0.1575082391500473, -0.1836964339017868, 0.13944111764431, 0.026699164882302284, -0.12828998267650604, -0.10416686534881592, -0.855417013168335, -1.1240910291671753, -0.3680402934551239, -0.5175941586494446, -0.8113775849342346, -0.48369184136390686, 0.42436426877975464, -0.24796444177627563, -0.7017632126808167, -0.33427396416664124, 0.8904720544815063, 0.13182073831558228, 0.0840996578335762, -1.3255901336669922, 0.555604100227356, 0.44455230236053467, 0.6097607612609863}, {-0.034049827605485916, 0.5697606801986694, -0.9041339755058289, 1.4350972175598145, -0.1483038365840912, -0.06558208167552948, -0.2450496107339859, -0.5598021149635315, 1.3650588989257812, 0.09695714712142944, 0.20738567411899567, -0.04335039108991623, 0.010373556055128574, 0.9249184727668762, 0.25404757261276245, 0.1163429543375969, -0.04122623801231384, 0.07139857113361359, 1.4624335765838623, 0.3055124580860138, 0.008223910816013813, -0.06609079241752625, 0.09183429181575775, 1.1958849430084229, 0.025186588987708092, 0.029254700988531113, 0.07879947870969772, -0.4418580234050751}, {0.07264219224452972, -0.8118353486061096, 0.5850833058357239, -0.04886290058493614, -0.21201711893081665, -0.2038731724023819, -0.044785141944885254, 0.33473384380340576, -0.3806909918785095, -0.3222631812095642, -0.1784955859184265, -0.07884243875741959, -0.04943345859646797, -0.7509729266166687, -0.2586313784122467, -0.11834448575973511, -0.3176766037940979, 0.029591834172606468, -0.6633329391479492, 0.31418582797050476, 0.1703609675168991, -0.1421850472688675, -0.09780556708574295, -2.4741933345794678, -0.007773654069751501, -0.2453930675983429, -0.10803715884685516, -0.10720524936914444}, {0.04180590435862541, -0.47792956233024597, 0.5036258101463318, -2.0397746562957764, 0.2890857756137848, 0.31826984882354736, 0.06372813880443573, -0.09525591135025024, -0.5323511362075806, 0.10418450832366943, 0.19146449863910675, 0.11332566291093826, -0.07695935666561127, -0.4690433442592621, -0.19135060906410217, 0.01175900548696518, -0.009661716409027576, 0.09737563133239746, -0.14801274240016937, -0.26320526003837585, -0.08077298104763031, -0.05239444971084595, -9.216830221703276e-05, -0.06783001869916916, -0.2219526469707489, -0.1100030168890953, 0.06168339401483536, -0.01574299857020378}}; -const 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 dense1_biases[DENSE_NUM] = +{-1.7320090532302856, -1.6262712478637695, -0.7219676971435547, -1.6883859634399414, -1.355366587638855, -1.4961345195770264, -1.6774159669876099, -1.9836738109588623, -1.8204424381256104, -1.6768863201141357, -1.5860340595245361, 0.4256221652030945, -1.9900296926498413, -2.060673952102661, -1.487168788909912, -1.653613567352295, -0.49618664383888245, -1.0318562984466553, -1.2956619262695312, -2.130068778991699, -2.124798536300659, -1.6073938608169556, -1.4884546995162964, -1.7450541257858276, -1.508810043334961, -1.4361188411712646, -1.4151768684387207, -1.6134501695632935, -1.9257988929748535, -1.8976153135299683, -1.6919738054275513, -1.7137935161590576, -0.9487504363059998, -0.7779767513275146, -2.0696449279785156, -0.4453120529651642, -0.8720207214355469, -2.00007963180542, -1.6582602262496948, -0.6423311233520508, -1.3238186836242676, -1.8345296382904053, -1.4237842559814453, -0.6334408521652222, -1.3415791988372803, -1.5188286304473877, -1.5377963781356812, -1.4456733465194702, -1.7134979963302612, -1.762224793434143, -1.760365605354309, -1.7037813663482666, -1.612302541732788, -1.613434910774231, -1.8743529319763184, -1.6047550439834595, -1.9443285465240479, -1.041770577430725, 0.48393940925598145, -1.487646460533142, -2.1693429946899414, -1.207763671875, -0.9444307684898376, -1.1276359558105469}; -const 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[2][DENSE_NUM] = +{{-0.1246807649731636, -0.08505872637033463, -0.0652783066034317, 0.1350107192993164, 0.1698562055826187, 0.400063693523407, 0.17860691249370575, -0.1349184215068817, 0.20356398820877075, 0.16311302781105042, -0.036207523196935654, 0.7803400754928589, -0.13074463605880737, -0.06796154379844666, 0.20493201911449432, 0.14702282845973969, -0.11247620731592178, 0.22241809964179993, 0.1635751873254776, -0.08345462381839752, -0.2028568834066391, 0.12081773579120636, -0.1835630089044571, 0.1626814305782318, 0.16333818435668945, -0.27365756034851074, 0.13540410995483398, -0.13346917927265167, -0.1633249968290329, 0.17652902007102966, 0.1970495879650116, -0.0996168851852417, 0.1257164627313614, -0.02319495752453804, 0.1254752278327942, 0.004205659963190556, -0.11657992005348206, -0.13747099041938782, -0.12851183116436005, -0.13266359269618988, 0.15070892870426178, 0.18036587536334991, -0.120721235871315, -0.07944180071353912, -0.07511389255523682, -0.14644883573055267, 0.11276227235794067, 0.1335425227880478, -0.12701821327209473, 0.20198681950569153, -0.06599707156419754, -0.14891819655895233, 0.2015286684036255, 0.17373384535312653, 0.1385129988193512, 0.1480085849761963, 0.20751388370990753, -0.127104252576828, -0.5856947302818298, -0.26959943771362305, -0.10330907255411148, 0.14857497811317444, -0.168384850025177, -0.23837287724018097}, {0.05711914226412773, 0.1704198718070984, 0.07292810082435608, -0.1523439884185791, -0.20949530601501465, -0.33654606342315674, -0.23295333981513977, 0.09389320015907288, -0.23792678117752075, -0.17215877771377563, 0.06109726428985596, -0.7076484560966492, 0.0808710902929306, 0.06764110177755356, -0.08750396966934204, -0.12129006534814835, 0.08196759223937988, -0.22181545197963715, -0.10018306225538254, 0.09599480032920837, 0.2410762906074524, -0.16045424342155457, 0.12080714106559753, -0.14531971514225006, -0.14728260040283203, 0.389263778924942, -0.14980417490005493, 0.14908818900585175, 0.1427009552717209, -0.18783621490001678, -0.17802631855010986, 0.10279617458581924, -0.1660611927509308, 0.03492075577378273, -0.0730394646525383, 0.011791321448981762, 0.09671367704868317, 0.10834173858165741, 0.12392941862344742, 0.08413772284984589, -0.18994614481925964, -0.20133660733699799, 0.07802799344062805, 0.06276662647724152, 0.06052928790450096, 0.12486152350902557, -0.10323746502399445, -0.1355014443397522, 0.16498015820980072, -0.2137404978275299, 0.10234697163105011, 0.12195070087909698, -0.15739789605140686, -0.13428226113319397, -0.0960799902677536, -0.1424444168806076, -0.18782544136047363, 0.14121107757091522, 0.6669175624847412, 0.2753967046737671, 0.09798707813024521, -0.16682972013950348, 0.1646665632724762, 0.24278126657009125}}; -const 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[2] = +{0.5831990242004395, 0.4281694293022156}; -const float output_bias = -0.027359746396541595; diff --git a/include/weights.h b/include/weights.h index ac5ede8..c4e0c3c 100644 --- a/include/weights.h +++ b/include/weights.h @@ -15,20 +15,11 @@ along with ct. If not, see . */ -#define KERN_SIZE 3 -#define KERN_CHAN 6 -#define KERN_NUM 12 -#define DENSE1_NUM 11 -#define DENSE2_NUM 8 +#define INP_NUM 3 + 5*5 +#define DENSE_NUM 64 -#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; +extern const float dense1_weights[DENSE_NUM][INP_NUM]; +extern const float dense1_biases[DENSE_NUM]; +extern const float output_weights[2][DENSE_NUM]; +extern const float output_bias[2]; diff --git a/resources/extract.sh b/resources/extract.sh index 2c4b153..d475a1d 100755 --- a/resources/extract.sh +++ b/resources/extract.sh @@ -2,67 +2,66 @@ db_file=games_anon.db -#chosen_players="AaaarghBot Tiltak_Bot TakticianBot" -chosen_players="" +chosen_players="AaaarghBot Tiltak_Bot TakticianBot" query() { - query="(size == $1) and (result != '1-0') and (result != '0-1') and (result != '0-0') and (result != '1/2-1/2')" - selct="" - for player in $chosen_players; do - selct="$selct(player_black == '$player') or (player_white == '$player') or " - done; - if [ -n "$selct" ]; then - query="$query and (${selct:0:-4})" - fi - echo "SELECT $2 FROM games WHERE $query;" + query="(size == $1) and (result != '1-0') and (result != '0-1') and (result != '0-0') and (result != '1/2-1/2')" + selct="" + for player in $chosen_players; do + selct="$selct(player_black = '$player') or (player_white = '$player') or " + done; + if [ -n "$selct" ]; then + query="$query and (${selct:0:-4})" + fi + echo "SELECT $2 FROM games WHERE $query;" } extract() { - size="$1" - things="$2" - if [ ! -f "data/$db_file" ]; then - curl "https://www.playtak.com/games_anon.db" -o "data/$db_file" - fi - echo Extracing games of size "$size"... - sqlite3 "data/$db_file" "$(query $size $things)" | shuf > "data/playtak-$size" + size="$1" + things="$2" + if [ ! -f "data/$db_file" ]; then + wget "https://www.playtak.com/games_anon.db" -O "data/$db_file" + fi + echo Extracing games of size "$size" with query: "$(query $size $things)" + sqlite3 "data/$db_file" "$(query $size $things)" | shuf > "data/playtak-$size" } -process() { - size=$1 - num_games=$2 - fn=$3 - - ./pptdb "$size" "data/playtak-$size" > "data/check-$size" - tail -n22 "data/check-$size" - echo -ne "\tStripping overflows and illegal games... " - grep -Fvxf "data/check-$size" "data/playtak-$size" > "data/good-playtak-$size-all" +prepare() { + size=$1 + ./pptdb "$size" "data/playtak-$size" > "data/check-$size" + tail -n22 "data/check-$size" + echo -ne "\tStripping overflows and illegal games... " + grep -Fvxf "data/check-$size" "data/playtak-$size" > "data/good-playtak-$size-all" + shuf "data/good-playtak-$size-all" > "data/good-playtak-$size" + rm "data/good-playtak-$size-all" - shuf "data/good-playtak-$size-all" > "data/good-playtak-$size" - rm "data/good-playtak-$size-all" + echo -en "Done.\n\tGenerating training data... " + ./pptdb "$size" "data/good-playtak-$size" generate +} - echo -en "Done.\n\tGenerating training data... " - ./pptdb "$size" "data/good-playtak-$size" generate +process() { + size=$1 + num_t=$2 + num_v=$3 + total=$(( num_t + num_v )) - echo -en "\tChoosing $num_games of $(wc -l data/training-$size.csv | cut -d\ -f1) samples... " - shuf -n $num_games "data/training-$size.csv" > "data/shuf-$size.csv" + echo -en "\tChoosing $num_t + $num_v = $total of $(wc -l data/parsed-$size.csv | cut -d\ -f1) samples... " + shuf -n $total "data/parsed-$size.csv" > "data/shuf-$size.csv" + head -n $num_t "data/shuf-$size.csv" > "data/training-$size.csv" + tail -n $num_v "data/shuf-$size.csv" > "data/validation-$size.csv" - echo -en "Done.\n\tCompressing data... " - mv "data/shuf-$size.csv" "data/$fn-$size.csv" - if [ -f "data/$fn-$size.csv.zst" ]; then - rm "data/$fn-$size.csv.zst" - fi - zstd --rm -13 "data/$fn-$size.csv" - echo "Done, available in data/$fn-$size.csv.zst" + echo "Done. " } if [ ! -d data ]; then - mkdir data + mkdir data fi make pptdb -for size in 6; do - echo - extract $size notation,result - process $size 1000000 training +for size in 5; do + echo + extract $size notation,result + prepare $size + process $size 1000000 20000 done diff --git a/src/cnn_train.py b/src/cnn_train.py deleted file mode 100644 index 4ba0a0b..0000000 --- a/src/cnn_train.py +++ /dev/null @@ -1,156 +0,0 @@ -# cnn_train.py, train a small CNN to recognise winning Tak positions -# -# 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 . - - -# Loading data -import pandas as pd -import numpy as np - -# Output of weights -from tensorflow import transpose - -# Custom activation function -from tensorflow import constant as k -from tensorflow import clip_by_value -from tensorflow.math import add, divide, multiply, square - -# Computing size -from tensorflow.keras.backend import get_value - -# Building models -from tensorflow.keras.models import Model -from tensorflow.keras.layers import Concatenate -from tensorflow.keras.layers import Input -from tensorflow.keras.layers import Dense -from tensorflow.keras.layers import Convolution2D -from tensorflow.keras.layers import Flatten - - -def load_data(size): - shape = (-1, size, size, 6) - # Load training data - tr_fn = "training-"+str(size)+".csv" - training_csv = pd.read_csv(tr_fn) - training_data = training_csv - training_stack_input = np.array(training_data.iloc[:, 2:-1]).reshape(shape, order='F') - training_flats_input = np.array(training_data.iloc[:, 0:2]) - training_input = [training_stack_input, training_flats_input] - training_outcome = training_data.iloc[:, -1:] - # Load validation data - val_fn = "validation-"+str(size)+".csv" - val_data = pd.read_csv(val_fn).tail(20000) - val_stack_input = np.array(val_data.iloc[:, 2:-1]).reshape(shape, order='F') - val_flats_input = np.array(val_data.iloc[:, 0:2]) - val_input = [val_stack_input, val_flats_input] - val_outcome = val_data.iloc[:, -1:] - return [(training_input, training_outcome), (val_input, val_outcome)] - - -# We need something that's close to 2*logistic-1, but cheaper to -# compute: (12+x+50*x/(x*x+10))/12-1, clipped between -1 and 1 as it -# would otherwise exceed this range at +- 4.6 or so -def clipped_pade_logistic(x): - val = add(k(12.0), - add(x, multiply(k(50.0), - divide(x, add(square(x), k(10.0)))))) - return clip_by_value(add(k(-1.0), divide(val, k(12.0))), -1.0, +1.0) - - -def train(size, model, data, iterations=1, epochs=10): - (training_input, training_outcome), (val_input, val_outcome) = data - results = [] - for i in range(0, iterations): - print("Iteration {0}/{1}".format(i+1, iterations)) - model.fit(training_input, training_outcome, epochs=epochs, - validation_data=(val_input, val_outcome), - verbose=True, batch_size=16) - v_loss = model.evaluate(val_input, val_outcome, - verbose=False, batch_size=16) - t_loss = model.evaluate(training_input, training_outcome, - verbose=False, batch_size=32) - results += [(v_loss, t_loss)] - write_weights(model, i+1, str((v_loss, t_loss))) - print("\nScores") - for i in range(len(results)): - print("Iteration {0}: {1}".format(i+1, results[i])) - return results - -def make_model(size, magic=[16, 128, 64, 64, 64]): - # Our model for the stacks, a small CNN - stack_shape = (size, size, 6) - stack_input = Input(shape=stack_shape) - stack_model = Convolution2D(magic[0], kernel_size=(3, 3), strides=(1, 1), - padding='valid', activation="relu", - use_bias=True)(stack_input) - stack_model = Flatten()(stack_model) - stack_model = Model(inputs=stack_input, outputs=stack_model) - # The overall model - flats_input = Input(shape=(2,)) - combn_input = Concatenate()([stack_model.output, flats_input]) - model = Dense(magic[1], activation="relu", use_bias=True)(combn_input) - model = Dense(magic[2], activation="relu", use_bias=True)(model) - model = Dense(1, activation=clipped_pade_logistic, use_bias=True)(model) - model = Model(inputs=[stack_model.input, flats_input], outputs=model) - model.compile(optimizer='adam', loss='mean_squared_error') - model.summary() - return model - - -def write_weights(model, iteration, performance): - def fix(val): - string = str(np.array(val).tolist()) - string = string.replace("[", "{").replace("]", "}") - return string - # Prepare everything in a sane memory order This isn't exactly in - # the correct order that tensorflow uses, because memory access - # out of order is an eyesore. Compared to tensorflow, the C - # implementation has the board reflected about the diagonal. - conv2d_weights = transpose(model.trainable_variables[0], perm=[3, 0, 1, 2]) - conv2d_biases = model.trainable_variables[1] - dense1_weights = transpose(model.trainable_variables[2], perm=[1, 0]) - dense1_biases = model.trainable_variables[3] - dense2_weights = transpose(model.trainable_variables[4], perm=[1, 0]) - dense2_biases = model.trainable_variables[5] - output_weights = transpose(model.trainable_variables[6], perm=[1, 0])[0] - output_bias = model.trainable_variables[7][0] - # Prepare formatting - names = ["conv2d_weights[KERN_NUM][KERN_SIZE][KERN_SIZE][KERN_CHAN]", - "conv2d_biases[KERN_NUM]", - "dense1_weights[DENSE1_NUM][CONV_NUM+2]", - "dense1_biases[DENSE1_NUM]", - "dense2_weights[DENSE2_NUM][DENSE1_NUM]", - "dense2_biases[DENSE2_NUM]", - "output_weights[DENSE2_NUM]", - "output_bias"] - variables = [conv2d_weights, conv2d_biases, - dense1_weights, dense1_biases, - dense2_weights, dense2_biases, - output_weights, output_bias] - # Write to file - f = open("weights-"+str(iteration)+".txt", "w") - f.write("/*\n") - model.summary(print_fn=lambda l: f.write(" * "+l+"\n")) - f.write(" * "+performance+"\n*/\n\n") - f.write("#include \"weights.h\"\n\n") - for (name, val) in zip(names, variables): - f.write("const float "+name+" =\n"+fix(val)+";\n\n") - f.close() - - -data = load_data(5) -model = make_model(5, [12, 11, 8]) -results = train(5, model, data, iterations=20, epochs=10) diff --git a/src/ctlm.c b/src/ctlm.c index e5ce2d5..a8bc194 100644 --- a/src/ctlm.c +++ b/src/ctlm.c @@ -235,41 +235,41 @@ static int handle_turn(char *line) { case GAME_END: { // Did it end this turn? if (new_win) { - switch (won) { - case WIN_DRAW: { - end_game(line, "1/2-1/2"); - break; - } - case WIN_FLAT_BLACK: { - end_game(line, "0-F"); - break; - } - case WIN_FLAT_WHITE: { - end_game(line, "F-0"); - break; - } - case WIN_ROAD_BLACK: { - end_game(line, "0-R"); - break; - } - case WIN_ROAD_WHITE: { - end_game(line, "R-0"); - break; - } - } + switch (won) { + case WIN_DRAW: { + end_game(line, "1/2-1/2"); + break; + } + case WIN_FLAT_BLACK: { + end_game(line, "0-F"); + break; + } + case WIN_FLAT_WHITE: { + end_game(line, "F-0"); + break; + } + case WIN_ROAD_BLACK: { + end_game(line, "0-R"); + break; + } + case WIN_ROAD_WHITE: { + end_game(line, "R-0"); + break; + } + } } puts("Enter `new' to play again."); if (!new_win) - return EXIT_FAILURE; + return EXIT_FAILURE; break; } // Valid, append to game log case ACT_OK: { append_to_gamelog(line, 0); if (auto_board) - print_board(); + print_board(); if (auto_info) - print_info(); + print_info(); break; } } @@ -383,7 +383,7 @@ static int negamax_turn(void) { static int input_is_not_turn(const char *line) { if (!strcmp(line, "help")) { - puts("Valid commands: auto (board|info), board, depth [0-9], eval,\ + puts("Valid commands: auto (board|info), board, depth [0-9], eval, \ help, info, load , log, new, play (b|w), self-play, square\ , tps, ."); } else if (!strcmp(line, "board")) { @@ -391,7 +391,7 @@ help, info, load , log, new, play (b|w), self-play, square\ } else if (!strcmp(line, "info")) { print_info(); } else if (!strcmp(line, "eval")) { - float eval = cnn1986_evaluate_black_win() * 100; + float eval = nn1986_evaluate_black_win() * 100; if (ply & 1) { printf("Black heuristic chance: %s%.2f%s\n", blk, eval, rst); } else { diff --git a/src/cttei.c b/src/cttei.c index aae1045..534faef 100644 --- a/src/cttei.c +++ b/src/cttei.c @@ -28,8 +28,8 @@ // Set up output function for negamax inline void negamax_display_progress(const uint8_t cur_depth, - const uint8_t init_depth, - const uint32_t length) { + const uint8_t init_depth, + const uint32_t length) { (void)(cur_depth); (void)(init_depth); (void)(length); @@ -81,7 +81,7 @@ handle_tei(char *line) { enum ACT_RESULT r = do_ptn(negamax_ptn); if (r != ACT_OK && r != GAME_END) return TEI_FAILURE; printf("info score cp %f pv %s\nbestmove %s\n", - minimax, negamax_ptn, negamax_ptn); + minimax, negamax_ptn, negamax_ptn); } else if (!strncmp(line, "position", 8)) { return parse_position_string(line + 9); } else if (!strncmp(line, "teinewgame", 10)) { @@ -126,7 +126,7 @@ int main(int argc, char **argv) { line = NULL; // Identify ourselves, and send the options - puts("id name cttei"); + puts("id name cttei_dense"); puts("id author tslil clingman"); puts("option name Depth type spin default 4 min 2 max 6"); puts("teiok"); @@ -141,15 +141,15 @@ int main(int argc, char **argv) { if ((read = getline(&line, &alloc_size, stdin)) > 0) { line[read-1] = 0; switch (handle_tei(line)) { - case TEI_FAILURE: return EXIT_FAILURE; - case TEI_QUIT: playing = 0; // fall-through - case TEI_OK: { - if (line) { - free(line); - line = NULL; - } - break; - } + case TEI_FAILURE: return EXIT_FAILURE; + case TEI_QUIT: playing = 0; // fall-through + case TEI_OK: { + if (line) { + free(line); + line = NULL; + } + break; + } } } else { break; diff --git a/src/nn_train.py b/src/nn_train.py new file mode 100644 index 0000000..12ce868 --- /dev/null +++ b/src/nn_train.py @@ -0,0 +1,106 @@ +# cnn_train.py, train a small CNN to recognise winning Tak positions +# +# 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 . + + +# Loading data +import pandas as pd +import numpy as np + +# Output of weights +from tensorflow import transpose + +# Building models +from tensorflow.keras.models import Model +from tensorflow.keras.layers import Input, Dense + + +def load_data(size): + output_len = 2 + # Load training data + tr_fn = "data/training-"+str(size)+".csv" + training_csv = pd.read_csv(tr_fn) + training_data = training_csv + training_input = np.array(training_data.iloc[:, 0:-output_len]) + training_outcome = np.array(training_data.iloc[:, -output_len:]) + # Load validation data + val_fn = "data/validation-"+str(size)+".csv" + val_data = pd.read_csv(val_fn) + val_input = np.array(val_data.iloc[:, 0:-output_len]) + val_outcome = np.array(val_data.iloc[:, -output_len:]) + return ((training_input, training_outcome), (val_input, val_outcome)) + + +def train(size, model, data, iterations=1, epochs=10, batch=None): + (tra_input, tra_outcome), (val_input, val_outcome) = data + results = [] + for i in range(0, iterations): + print("Iteration {0}/{1}".format(i+1, iterations)) + model.fit(tra_input, tra_outcome, epochs=epochs, + validation_data=(val_input, val_outcome), + verbose=True, batch_size=batch) + val_res = model.evaluate(val_input, val_outcome, verbose=False) + tra_res = model.evaluate(tra_input, tra_outcome, verbose=False) + results.append((tra_res, val_res)) + print(val_res) + write_weights(model, i+1, (tra_res, val_res)) + print("\nScores") + for i, data in enumerate(results): + print(f"Iteration {i}: {data}") + return results + + +def make_model(size, magic): + inputs = Input(shape=(size * size + 3,)) + model = inputs + model = Dense(magic, activation="relu", use_bias=True)(model) + model = Dense(2, activation="relu", use_bias=True)(model) + model = Model(inputs=inputs, outputs=model) + model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy']) + model.summary() + return model + + +def write_weights(model, iteration, performance): + def fix(val): + string = str(np.array(val).tolist()) + string = string.replace("[", "{").replace("]", "}") + return string + dense1_weights = transpose(model.trainable_variables[0], perm=[1, 0]) + dense1_biases = model.trainable_variables[1] + output_weights = transpose(model.trainable_variables[2], perm=[1, 0]) + output_bias = model.trainable_variables[3] + # Prepare output + to_output = [("dense1_weights[DENSE_NUM][INP_NUM]",dense1_weights) + ("dense1_biases[DENSE_NUM]", dense1_biases), + ("output_weights[2][DENSE_NUM]", output_weights), + ("output_bias[2]", output_bias)] + # Write to file + f = open("weights-"+str(iteration)+".txt", "w") + f.write("/*\n") + model.summary(print_fn=lambda l: f.write(" * "+l+"\n")) + f.write(" * "+str(performance)+"\n*/\n\n") + f.write("#include \"weights.h\"\n\n") + for (name, val) in to_output: + f.write("const float "+name+" =\n"+fix(val)+";\n\n") + f.close() + + +data = load_data(5) +model = make_model(5, 64) + +print("Before training", model.evaluate(data[1][0], data[1][1], verbose=False, batch_size=16)) +results = train(5, model, data, iterations=1, epochs=10, batch=None) diff --git a/src/pptdb.c b/src/pptdb.c index eeebf2a..42e8706 100644 --- a/src/pptdb.c +++ b/src/pptdb.c @@ -27,125 +27,119 @@ int generate; uint64_t heights[16]; FILE *training_fh = NULL; -float max_flats, outcome_black; +float max_flats; +uint8_t outcome_black; 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 < board_size + 1; depth++) { + // Two numbers for flats remaining + fprintf(training_fh,"%d,%.8f,%.8f,", + ply & 1 ? 1 : -1, + (float)(white_count & 127)/max_flats, + (float)(black_count & 127)/max_flats); + + // Write the board layers + float val; + int col, row; 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<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)>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.50 : -0.50; + } } + fprintf(training_fh,"%.2f,", val); + } } - } - fprintf(training_fh,"%.1f\n", outcome_black); + fprintf(training_fh, "%d,%d\n", outcome_black ? 1 : 0, outcome_black ? 0 : 1); } // 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 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+21) heights[COUNT_AT(k)]+=1; - } - } + ssize_t idx; + enum ACT_RESULT r; + int total_plies = 0; + + for (idx=0;idx= total_plies) { - write_input(+1, +1, 1); write_input(+1, +1, 0); - write_input(+1, -1, 1); write_input(+1, -1, 0); - write_input(-1, +1, 1); write_input(-1, +1, 0); - write_input(-1, -1, 1); write_input(-1, -1, 0); + 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+21) heights[COUNT_AT(k)]+=1; + } + } + } + // Generate training data, not too early in the game and not at + // the end, under all eight symmetries of the board + if (generate && ply > 7 && ply < total_plies && ply + 10 >= total_plies) { + write_input(+1, +1, 1); write_input(+1, +1, 0); + write_input(+1, -1, 1); write_input(+1, -1, 0); + write_input(-1, +1, 1); write_input(-1, +1, 0); + write_input(-1, -1, 1); write_input(-1, -1, 0); + } + // Parse next action + while (idx=read) return ACT_OK; + next_ply(); } - // Parse next action - while (idx=read) return ACT_OK; - next_ply(); - } - return ACT_OK; + return ACT_OK; } const char* license = "pptdb, generate neural network training data from a playtak.com database dump\n\ @@ -155,92 +149,91 @@ Copyright (C) 2021, tslil clingman\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'; - - playtak_fh = fopen(argv[2], "r"); - if (playtak_fh == NULL) exit(EXIT_FAILURE); - - if (argc > 3 && (!strncmp("generate", argv[3], 8))) { - generate=1; - max_flats = (size == 5) ? 21.0 : 30.0; - snprintf(td_fn, 64, "data/training-%d.csv",size); - training_fh = fopen(td_fn, "w"); - if (training_fh == NULL) exit(EXIT_FAILURE); - } else generate=0; - - while ((read = getline(&line, &len, playtak_fh)) != -1) { - // Reset everything - reset_state(size); - // Store the outcome of this game. Black win = 1 - 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 (generate == 0) { - 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++; - } + (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'; + + playtak_fh = fopen(argv[2], "r"); + if (playtak_fh == NULL) exit(EXIT_FAILURE); + + if (argc > 3 && (!strncmp("generate", argv[3], 8))) { + generate=1; + max_flats = (size == 5) ? 21.0 : 30.0; + snprintf(td_fn, 64, "data/parsed-%d.csv",size); + training_fh = fopen(td_fn, "w"); + if (training_fh == NULL) exit(EXIT_FAILURE); + } else generate=0; + + while ((read = getline(&line, &len, playtak_fh)) != -1) { + // Reset everything + reset_state(size); + // Store the outcome of this game. Black win = 1 + outcome_black = (line[read-4] == '0'); + // Parse the line + r = parse_line(line,read-4); + // Adjust counts if we're not generating training data + if (generate == 0) { + 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++; } - games++; - } - fclose(playtak_fh); - if (generate) fclose(training_fh); - if (line) free(line); + fclose(playtak_fh); + if (generate) fclose(training_fh); + if (line) free(line); - if (illegal || overflow) putchar('\n'); - printf("Read %d games\n",games); + if (illegal || overflow) putchar('\n'); + printf("Read %d games\n",games); - if (generate==0) { - printf("Illegals: %d\nOverflows: %d\n\ + if (generate==0) { + 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]); + 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]); + } } - } - exit(EXIT_SUCCESS); + exit(EXIT_SUCCESS); } -- cgit v1.2.3