diff --git a/src/cnn/creation.c b/src/cnn/creation.c index 7305602..2ff2559 100644 --- a/src/cnn/creation.c +++ b/src/cnn/creation.c @@ -3,6 +3,7 @@ #include "../include/memory_management.h" #include "include/initialisation.h" +#include "../include/colors.h" #include "include/function.h" #include "../include/utils.h" @@ -10,7 +11,7 @@ Network* create_network(int max_size, float learning_rate, int dropout, int initialisation, int input_dim, int input_depth) { if (dropout < 0 || dropout > 100) { - printf("Erreur, la probabilité de dropout n'est pas respecté, elle doit être comprise entre 0 et 100\n"); + printf_error("la probabilité de dropout n'est pas respecté, elle doit être comprise entre 0 et 100\n"); } Network* network = (Network*)nalloc(1, sizeof(Network)); network->learning_rate = learning_rate; @@ -102,11 +103,11 @@ void add_2d_average_pooling(Network* network, int dim_output) { int k_pos = n-1; int dim_input = network->width[k_pos]; if (network->max_size == n) { - printf("Impossible de rajouter une couche d'average pooling, le réseau est déjà plein\n"); + printf_error("Impossible de rajouter une couche d'average pooling, le réseau est déjà plein\n"); return; } if (dim_input%dim_output != 0) { - printf("Erreur de dimension dans l'average pooling\n"); + printf_error("Dimension de l'average pooling incorrecte\n"); return; } network->kernel[k_pos]->cnn = NULL; @@ -124,11 +125,11 @@ void add_2d_max_pooling(Network* network, int dim_output) { int k_pos = n-1; int dim_input = network->width[k_pos]; if (network->max_size == n) { - printf("Impossible de rajouter une couche de max pooling, le réseau est déjà plein\n"); + printf_error("Impossible de rajouter une couche de max pooling, le réseau est déjà plein\n"); return; } if (dim_input%dim_output != 0) { - printf("Erreur de dimension dans le max pooling\n"); + printf_error("Dimension du max pooling incorrecte\n"); return; } network->kernel[k_pos]->cnn = NULL; @@ -145,7 +146,7 @@ void add_convolution(Network* network, int depth_output, int dim_output, int act int n = network->size; int k_pos = n-1; if (network->max_size == n) { - printf("Impossible de rajouter une couche de convolution, le réseau est déjà plein \n"); + printf_error("Impossible de rajouter une couche de convolution, le réseau est déjà plein \n"); return; } int depth_input = network->depth[k_pos]; @@ -207,7 +208,7 @@ void add_dense(Network* network, int size_output, int activation) { int k_pos = n-1; int size_input = network->width[k_pos]; if (network->max_size == n) { - printf("Impossible de rajouter une couche dense, le réseau est déjà plein\n"); + printf_error("Impossible de rajouter une couche dense, le réseau est déjà plein\n"); return; } network->kernel[k_pos]->cnn = NULL; @@ -248,7 +249,7 @@ void add_dense_linearisation(Network* network, int size_output, int activation) int k_pos = n-1; int size_input = network->depth[k_pos]*network->width[k_pos]*network->width[k_pos]; if (network->max_size == n) { - printf("Impossible de rajouter une couche dense, le réseau est déjà plein\n"); + printf_error("Impossible de rajouter une couche dense, le réseau est déjà plein\n"); return; } network->kernel[k_pos]->cnn = NULL; diff --git a/src/cnn/export.c b/src/cnn/export.c index 6de4866..5a2d166 100644 --- a/src/cnn/export.c +++ b/src/cnn/export.c @@ -4,6 +4,7 @@ #include "include/free.h" #include "include/struct.h" +#include "../include/colors.h" #include "include/neuron_io.h" @@ -67,7 +68,7 @@ void print_poids_ker_cnn(char* modele) { int main(int argc, char* argv[]) { if (argc < 2) { - printf("Pas d'action spécifiée\n"); + printf_error("Pas d'action spécifiée\n"); help(argv[0]); return 1; } @@ -79,18 +80,20 @@ int main(int argc, char* argv[]) { modele = argv[i+1]; i += 2; } else { - printf("Option choisie inconnue: %s\n", argv[i]); + printf_warning("Option choisie inconnue: "); + printf("%s\n", argv[i]); i++; } } if (!modele) { - printf("Pas de modèle à utiliser spécifié.\n"); + printf_error("Pas de modèle à utiliser spécifié.\n"); return 1; } print_poids_ker_cnn(modele); return 0; } - printf("Option choisie non reconnue: %s\n", argv[1]); + printf_error("Option choisie non reconnue: "); + printf("%s\n", argv[1]); help(argv[0]); return 1; } \ No newline at end of file diff --git a/src/cnn/function.c b/src/cnn/function.c index 1961984..b9a0410 100644 --- a/src/cnn/function.c +++ b/src/cnn/function.c @@ -2,6 +2,8 @@ #include #include +#include "../include/colors.h" + #include "include/function.h" @@ -107,7 +109,8 @@ void choose_apply_function_matrix(int activation, float*** input, int depth, int } else if (activation == LEAKY_RELU) { apply_function_input(leaky_relu, input, depth, dim, dim); } else { - printf("Erreur, fonction d'activation inconnue (choose_apply_function_matrix): %d\n", activation); + printf_error("fonction d'activation inconnue (apply_function_to_matrix): "); + printf("%d\n", activation); } } @@ -123,7 +126,8 @@ void choose_apply_function_vector(int activation, float*** input, int dim) { } else if (activation == LEAKY_RELU) { apply_function_input(leaky_relu, input, 1, 1, dim); } else { - printf("Erreur, fonction d'activation inconnue (choose_apply_function_vector): %d\n", activation); + printf_error("fonction d'activation inconnue (apply_function_to_vector): "); + printf("%d\n", activation); } } @@ -147,11 +151,11 @@ ptr get_function_activation(int activation) { return &sigmoid_derivative; } if (activation == SOFTMAX) { - printf("Erreur, impossible de renvoyer la fonction softmax\n"); + printf_error("impossible de renvoyer la fonction softmax\n"); return NULL; } if (activation == -SOFTMAX) { - printf("Erreur, impossible de renvoyer la dérivée de la fonction softmax\n"); + printf_error("impossible de renvoyer la dérivée de la fonction softmax\n"); return NULL; } if (activation == TANH) { @@ -166,6 +170,7 @@ ptr get_function_activation(int activation) { if (activation == -LEAKY_RELU) { return &leaky_relu_derivative; } - printf("Erreur, fonction d'activation inconnue (choose_apply_function_vector): %d\n", activation); + printf_error("fonction d'activation inconnue (get_activation_function): "); + printf("%d\n", activation); return NULL; } diff --git a/src/cnn/main.c b/src/cnn/main.c index ccec369..2fe2d46 100644 --- a/src/cnn/main.c +++ b/src/cnn/main.c @@ -45,7 +45,7 @@ void help(char* call) { int main(int argc, char* argv[]) { if (argc < 2) { - printf("Pas d'action spécifiée\n"); + printf_error("Pas d'action spécifiée\n"); help(argv[0]); return 1; } @@ -87,30 +87,31 @@ int main(int argc, char* argv[]) { recover = argv[i+1]; i += 2; } else { - printf("Option choisie inconnue: %s\n", argv[i]); + printf_warning("Option choisie inconnue: "); + printf("%s\n", argv[i]); i++; } } if ((dataset!=NULL) && !strcmp(dataset, "mnist")) { dataset_type = 0; if (!images_file) { - printf("Pas de fichier d'images spécifié\n"); + printf_error("Pas de fichier d'images spécifié\n"); return 1; } if (!labels_file) { - printf("Pas de fichier de labels spécifié\n"); + printf_error("Pas de fichier de labels spécifié\n"); return 1; } } else if ((dataset!=NULL) && !strcmp(dataset, "jpg")) { dataset_type = 1; if (!data_dir) { - printf("Pas de dossier de données spécifié.\n"); + printf_error("Pas de dossier de données spécifié.\n"); return 1; } } else { - printf("Pas de type de dataset spécifié.\n"); + printf_error("Pas de type de dataset spécifié.\n"); return 1; } if (!out) { @@ -155,35 +156,36 @@ int main(int argc, char* argv[]) { i++; } else { - printf("Option choisie inconnue: %s\n", argv[i]); + printf_warning("Option choisie inconnue: "); + printf("%s\n", argv[i]); i++; } } if ((dataset!=NULL) && !strcmp(dataset, "mnist")) { dataset_type = 0; if (!images_file) { - printf("Pas de fichier d'images spécifié\n"); + printf_error("Pas de fichier d'images spécifié\n"); return 1; } if (!labels_file) { - printf("Pas de fichier de labels spécifié\n"); + printf_error("Pas de fichier de labels spécifié\n"); return 1; } } else if ((dataset!=NULL) && !strcmp(dataset, "jpg")) { dataset_type = 1; if (!data_dir) { - printf("Pas de dossier de données spécifié.\n"); + printf_error("Pas de dossier de données spécifié.\n"); return 1; } } else { - printf("Pas de type de dataset spécifié.\n"); + printf_error("Pas de type de dataset spécifié.\n"); return 1; } if (!modele) { - printf("Pas de modèle à utiliser spécifié.\n"); + printf_error("Pas de modèle à utiliser spécifié.\n"); return 1; } test_network(dataset_type, modele, images_file, labels_file, data_dir, preview_fails); @@ -213,7 +215,8 @@ int main(int argc, char* argv[]) { input_file = argv[i+1]; i += 2; } else { - printf("Option choisie inconnue: %s\n", argv[i]); + printf_warning("Option choisie inconnue: "); + printf("%s\n", argv[i]); i++; } } @@ -223,24 +226,25 @@ int main(int argc, char* argv[]) { dataset_type = 1; } else { - printf("Pas de type de dataset spécifié.\n"); + printf_error("Pas de type de dataset spécifié.\n"); return 1; } if (!input_file) { - printf("Pas de fichier d'entrée spécifié, rien à faire.\n"); + printf_error("Pas de fichier d'entrée spécifié, rien à faire.\n"); return 1; } if (!out) { out = "text"; } if (!modele) { - printf("Pas de modèle à utiliser spécifié.\n"); + printf_error("Pas de modèle à utiliser spécifié.\n"); return 1; } recognize(dataset_type, modele, input_file, out); return 0; } - printf("Option choisie non reconnue: %s\n", argv[1]); + printf_error("Option choisie non reconnue: "); + printf("%s\n", argv[1]); help(argv[0]); return 1; } \ No newline at end of file diff --git a/src/cnn/neuron_io.c b/src/cnn/neuron_io.c index 7fc9ab9..15ff137 100644 --- a/src/cnn/neuron_io.c +++ b/src/cnn/neuron_io.c @@ -153,7 +153,7 @@ Network* read_network(char* filename) { fread(&magic, sizeof(uint32_t), 1, ptr); if (magic != MAGIC_NUMBER) { - printf("Incorrect magic number !\n"); + printf_error("Incorrect magic number !\n"); exit(1); }