From a16aec693c4dc2a07710ea87420f62af17394170 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Mon, 11 Apr 2022 19:57:09 +0200 Subject: [PATCH] Fix --- src/mnist/main.c | 9 +++++---- src/webserver/static/script.js | 12 ++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/mnist/main.c b/src/mnist/main.c index 73d9bea..26b73d2 100644 --- a/src/mnist/main.c +++ b/src/mnist/main.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "neural_network.c" #include "neuron_io.c" @@ -9,7 +10,7 @@ int indice_max(float* tab, int n) { int indice = -1; - float maxi = 0.; + float maxi = FLT_MIN; for (int i=0; i < n; i++) { if (tab[i] > maxi) { @@ -96,7 +97,7 @@ void train(int batches, int couches, int neurons, char* recovery, char* image_fi forward_propagation(reseau); for (int k=0; k < nb_neurones_der; k++) { - sortie[k] = der_couche->neurones[k]->activation; + sortie[k] = der_couche->neurones[k]->z; } if (indice_max(sortie, nb_neurones_der) == labels[j]) { accuracy += 1. / (float)nb_images; @@ -137,13 +138,13 @@ void recognize(char* modele, char* entree, char* sortie) { for (int j=0; j < derniere_couche->nb_neurones; j++) { if (! strcmp(sortie, "json")) { - printf("%f", derniere_couche->neurones[j]->activation); // CHECK: ->activation ou ->z + printf("%f", derniere_couche->neurones[j]->z); if (j+1 < derniere_couche->nb_neurones) { printf(", "); } } else - printf("Probabilité %d: %f\n", j, derniere_couche->neurones[j]->activation); // CHECK: ->activation ou ->z + printf("Probabilité %d: %f\n", j, derniere_couche->neurones[j]->z); } if (! strcmp(sortie, "json")) { if (i+1 < nb_images) { diff --git a/src/webserver/static/script.js b/src/webserver/static/script.js index 2b92c6d..e90df6b 100644 --- a/src/webserver/static/script.js +++ b/src/webserver/static/script.js @@ -38,7 +38,7 @@ function draw(ctx, x, y, isDown) { ctx.beginPath(); // On choisit les options suivantes: ctx.strokeStyle = "white"; - ctx.lineWidth = "10"; + ctx.lineWidth = "12"; ctx.lineJoin = "round"; ctx.lineCap = "round"; ctx.moveTo(lastX, lastY); @@ -126,10 +126,10 @@ function getPrediction() { let tableau = []; let tmp_tableau = []; - while (curWidth < totalWidth) { - curHeight = 0; + while (curHeight < totalHeight) { + curWidth = 0; tmp_tableau = []; - while (curHeight < totalHeight) { + while (curWidth < totalWidth) { data = ctx.getImageData(curWidth, curHeight, stepSize, stepSize); size = data.width * data.height; density = 0; @@ -140,9 +140,9 @@ function getPrediction() { density = density*1.0 / size; tmp_tableau.push(density); - curHeight += stepSize; + curWidth += stepSize; } - curWidth += stepSize; + curHeight += stepSize; tableau.push(tmp_tableau); }