mirror of
https://github.com/augustin64/projet-tipe
synced 2025-01-24 07:36:24 +01:00
Fix
This commit is contained in:
parent
1b2cb44df0
commit
a16aec693c
@ -1,6 +1,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
#include "neural_network.c"
|
#include "neural_network.c"
|
||||||
#include "neuron_io.c"
|
#include "neuron_io.c"
|
||||||
@ -9,7 +10,7 @@
|
|||||||
|
|
||||||
int indice_max(float* tab, int n) {
|
int indice_max(float* tab, int n) {
|
||||||
int indice = -1;
|
int indice = -1;
|
||||||
float maxi = 0.;
|
float maxi = FLT_MIN;
|
||||||
|
|
||||||
for (int i=0; i < n; i++) {
|
for (int i=0; i < n; i++) {
|
||||||
if (tab[i] > maxi) {
|
if (tab[i] > maxi) {
|
||||||
@ -96,7 +97,7 @@ void train(int batches, int couches, int neurons, char* recovery, char* image_fi
|
|||||||
forward_propagation(reseau);
|
forward_propagation(reseau);
|
||||||
|
|
||||||
for (int k=0; k < nb_neurones_der; k++) {
|
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]) {
|
if (indice_max(sortie, nb_neurones_der) == labels[j]) {
|
||||||
accuracy += 1. / (float)nb_images;
|
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++) {
|
for (int j=0; j < derniere_couche->nb_neurones; j++) {
|
||||||
if (! strcmp(sortie, "json")) {
|
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) {
|
if (j+1 < derniere_couche->nb_neurones) {
|
||||||
printf(", ");
|
printf(", ");
|
||||||
}
|
}
|
||||||
} else
|
} 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 (! strcmp(sortie, "json")) {
|
||||||
if (i+1 < nb_images) {
|
if (i+1 < nb_images) {
|
||||||
|
@ -38,7 +38,7 @@ function draw(ctx, x, y, isDown) {
|
|||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
// On choisit les options suivantes:
|
// On choisit les options suivantes:
|
||||||
ctx.strokeStyle = "white";
|
ctx.strokeStyle = "white";
|
||||||
ctx.lineWidth = "10";
|
ctx.lineWidth = "12";
|
||||||
ctx.lineJoin = "round";
|
ctx.lineJoin = "round";
|
||||||
ctx.lineCap = "round";
|
ctx.lineCap = "round";
|
||||||
ctx.moveTo(lastX, lastY);
|
ctx.moveTo(lastX, lastY);
|
||||||
@ -126,10 +126,10 @@ function getPrediction() {
|
|||||||
let tableau = [];
|
let tableau = [];
|
||||||
let tmp_tableau = [];
|
let tmp_tableau = [];
|
||||||
|
|
||||||
while (curWidth < totalWidth) {
|
|
||||||
curHeight = 0;
|
|
||||||
tmp_tableau = [];
|
|
||||||
while (curHeight < totalHeight) {
|
while (curHeight < totalHeight) {
|
||||||
|
curWidth = 0;
|
||||||
|
tmp_tableau = [];
|
||||||
|
while (curWidth < totalWidth) {
|
||||||
data = ctx.getImageData(curWidth, curHeight, stepSize, stepSize);
|
data = ctx.getImageData(curWidth, curHeight, stepSize, stepSize);
|
||||||
size = data.width * data.height;
|
size = data.width * data.height;
|
||||||
density = 0;
|
density = 0;
|
||||||
@ -140,9 +140,9 @@ function getPrediction() {
|
|||||||
density = density*1.0 / size;
|
density = density*1.0 / size;
|
||||||
|
|
||||||
tmp_tableau.push(density);
|
tmp_tableau.push(density);
|
||||||
curHeight += stepSize;
|
|
||||||
}
|
|
||||||
curWidth += stepSize;
|
curWidth += stepSize;
|
||||||
|
}
|
||||||
|
curHeight += stepSize;
|
||||||
tableau.push(tmp_tableau);
|
tableau.push(tmp_tableau);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user