This commit is contained in:
augustin64 2022-05-23 17:27:38 +02:00
parent 7a0182b5a9
commit 0c49729e0e
5 changed files with 14 additions and 2 deletions

View File

@ -249,7 +249,7 @@ float** recognize(char* modele, char* entree) {
}
}
deletion_of_network(network);
free(parameters);
return results;
}
@ -283,6 +283,7 @@ void print_recognize(char* modele, char* entree, char* sortie) {
} else
printf("Probabilité %d: %f\n", j, resultats[i][j]);
}
free(resultats[i]);
if (! strcmp(sortie, "json")) {
if (i+1 < nb_images) {
printf("],\n");
@ -291,10 +292,11 @@ void print_recognize(char* modele, char* entree, char* sortie) {
}
}
}
free(resultats);
free(parameters);
if (! strcmp(sortie, "json")) {
printf("}\n");
}
}
void test(char* modele, char* fichier_images, char* fichier_labels, bool preview_fails) {
@ -320,8 +322,11 @@ void test(char* modele, char* fichier_images, char* fichier_labels, bool preview
printf("--- Image %d, %d --- Prévision: %d ---\n", i, labels[i], indice_max(resultats[i], nb_last_layer));
print_image(width, height, images[i], resultats[i]);
}
free(resultats[i]);
}
printf("%d Images\tAccuracy: %0.1f%%\n", nb_images, accuracy*100);
free(parameters);
free(resultats);
}

View File

@ -89,9 +89,11 @@ void deletion_of_network(Network* network) {
free(neuron->weights);
free(neuron->back_weights);
free(neuron->last_back_weights);
free(neuron);
}
}
free(layer->neurons); // On libère enfin la liste des neurones de la couche
free(network->layers[i]);
}
free(network->layers);
free(network); // Pour finir, on libère le réseau neuronal contenant la liste des couches

View File

@ -75,6 +75,7 @@ void count_labels(char* filename) {
for (int i=0; i < 10; i++) {
printf("Nombre de %d: %x\n", i, tab[i]);
}
free(labels);
}
void create_network(char* filename, int sortie) {

View File

@ -24,5 +24,6 @@ int main() {
write_network(".test-cache/random_network.bin", network);
printf("OK\n");
deletion_of_network(network);
return 0;
}

View File

@ -4,6 +4,7 @@
#include <inttypes.h>
#include "../src/mnist/neuron_io.c"
#include "../src/mnist/neural_network.c"
Neuron* creer_neuron(int nb_sortants) {
@ -70,5 +71,7 @@ int main() {
printf("Vérification de l'accès en lecture\n");
Network* network2 = read_network(".test-cache/neuron_io.bin");
printf("OK\n");
deletion_of_network(network);
deletion_of_network(network2);
return 0;
}