From 5bb43ff5a71765fb9593b6a8d6060fbf5df87926 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Fri, 8 Apr 2022 16:07:44 +0200 Subject: [PATCH] Add recognize --- src/mnist/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/mnist/main.c b/src/mnist/main.c index 0fa206e..c46ce02 100644 --- a/src/mnist/main.c +++ b/src/mnist/main.c @@ -35,6 +35,7 @@ void ecrire_image_dans_reseau(int** image, Reseau* reseau, int height, int width void train(int batches, int couches, int neurons, char* recovery, char* image_file, char* label_file, char* out) { + // Entraînement du réseau sur le set de données MNIST Reseau* reseau; //int* repartition = malloc(sizeof(int)*couches); @@ -73,10 +74,32 @@ void train(int batches, int couches, int neurons, char* recovery, char* image_fi backward_propagation(reseau, sortie_voulue); } printf("\n"); + modification_du_reseau_neuronal(reseau); ecrire_reseau(out, reseau); } } +void recognize(char* modele, char* entree, char* sortie) { + Reseau* reseau = lire_reseau(modele); + + int* parameters = read_mnist_images_parameters(entree); + int nb_images = parameters[0]; + int height = parameters[1]; + int width = parameters[2]; + + int*** images = read_mnist_images(entree); + + for (int i=0; i < nb_images; i++) { + printf("Image %d\n", i); + ecrire_image_dans_reseau(images[i], reseau, height, width); + forward_propagation(reseau); + for (int j=0; j < reseau->couches[reseau->nb_couches-1]->nb_neurones; j++) { + printf("Probabilité %d: %f\n", j, reseau->couches[reseau->nb_couches-1]->neurones[j]->activation); + } + } + +} + int main(int argc, char* argv[]) { if (argc < 2) { @@ -169,6 +192,7 @@ int main(int argc, char* argv[]) { if (! out) { out = "text"; } + recognize(modele, in, out); // Reconnaissance puis affichage des données sous le format spécifié exit(0); }