mirror of
https://github.com/augustin64/projet-tipe
synced 2025-01-24 07:36:24 +01:00
Corrections d'erreurs de traduction
This commit is contained in:
parent
be8d87d4be
commit
f164236b5f
@ -7,8 +7,11 @@
|
|||||||
#include "neuron_io.c"
|
#include "neuron_io.c"
|
||||||
#include "mnist.c"
|
#include "mnist.c"
|
||||||
|
|
||||||
#define EPOCHS 10
|
#define EPOCHS 100
|
||||||
#define BATCHES 50
|
#define BATCHES 100
|
||||||
|
|
||||||
|
#define IS_LEARNING true
|
||||||
|
|
||||||
|
|
||||||
void print_image(unsigned int width, unsigned int height, int** image, float* previsions) {
|
void print_image(unsigned int width, unsigned int height, int** image, float* previsions) {
|
||||||
char tab[] = {' ', '.', ':', '%', '#', '\0'};
|
char tab[] = {' ', '.', ':', '%', '#', '\0'};
|
||||||
@ -42,20 +45,20 @@ void help(char* call) {
|
|||||||
printf("OPTIONS:\n");
|
printf("OPTIONS:\n");
|
||||||
printf("\ttrain:\n");
|
printf("\ttrain:\n");
|
||||||
printf("\t\t--batches | -b [int]\tNombre de batches.\n");
|
printf("\t\t--batches | -b [int]\tNombre de batches.\n");
|
||||||
printf("\t\t--layers | -c [int]\tNombres de layers.\n");
|
printf("\t\t--couches | -c [int]\tNombres de couches.\n");
|
||||||
printf("\t\t--neurons | -n [int]\tNombre de neurons sur la première layer.\n");
|
printf("\t\t--neurones | -n [int]\tNombre de neurones sur la première couche.\n");
|
||||||
printf("\t\t--recover | -r [FILENAME]\tRécupérer depuis un modèle existant.\n");
|
printf("\t\t--recover | -r [FILENAME]\tRécupérer depuis un modèle existant.\n");
|
||||||
printf("\t\t--images | -i [FILENAME]\tFichier contenant les images.\n");
|
printf("\t\t--images | -i [FILENAME]\tFichier contenant les images.\n");
|
||||||
printf("\t\t--labels | -l [FILENAME]\tFichier contenant les labels.\n");
|
printf("\t\t--labels | -l [FILENAME]\tFichier contenant les labels.\n");
|
||||||
printf("\t\t--out | -o [FILENAME]\tFichier où écrire le réseau de neurons.\n");
|
printf("\t\t--out | -o [FILENAME]\tFichier où écrire le réseau de neurones.\n");
|
||||||
printf("\trecognize:\n");
|
printf("\trecognize:\n");
|
||||||
printf("\t\t--modele | -m [FILENAME]\tFichier contenant le réseau de neurons.\n");
|
printf("\t\t--modele | -m [FILENAME]\tFichier contenant le réseau de neurones.\n");
|
||||||
printf("\t\t--in | -i [FILENAME]\tFichier contenant les images à reconnaître.\n");
|
printf("\t\t--in | -i [FILENAME]\tFichier contenant les images à reconnaître.\n");
|
||||||
printf("\t\t--out | -o (text|json)\tFormat de sortie.\n");
|
printf("\t\t--out | -o (text|json)\tFormat de sortie.\n");
|
||||||
printf("\ttest:\n");
|
printf("\ttest:\n");
|
||||||
printf("\t\t--images | -i [FILENAME]\tFichier contenant les images.\n");
|
printf("\t\t--images | -i [FILENAME]\tFichier contenant les images.\n");
|
||||||
printf("\t\t--labels | -l [FILENAME]\tFichier contenant les labels.\n");
|
printf("\t\t--labels | -l [FILENAME]\tFichier contenant les labels.\n");
|
||||||
printf("\t\t--modele | -m [FILENAME]\tFichier contenant le réseau de neurons.\n");
|
printf("\t\t--modele | -m [FILENAME]\tFichier contenant le réseau de neurones.\n");
|
||||||
printf("\t\t--preview-fails | -p\tAfficher les images ayant échoué.\n");
|
printf("\t\t--preview-fails | -p\tAfficher les images ayant échoué.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,12 +132,12 @@ void train(int batches, int layers, int neurons, char* recovery, char* image_fil
|
|||||||
loss += loss_computing(network, labels[j]) / (float)nb_images;
|
loss += loss_computing(network, labels[j]) / (float)nb_images;
|
||||||
free(desired_output);
|
free(desired_output);
|
||||||
|
|
||||||
if (j%BATCHES==BATCHES-1)
|
if (j%BATCHES==BATCHES-1 && IS_LEARNING)
|
||||||
network_modification(network, BATCHES);
|
network_modification(network, BATCHES);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nb_images%BATCHES != 0)
|
if (nb_images%BATCHES != 0 && IS_LEARNING)
|
||||||
network_modification(network, nb_images%BATCHES);
|
network_modification(network, nb_images%BATCHES);
|
||||||
|
|
||||||
printf("\rBatch [%d/%d]\tImage [%d/%d]\tAccuracy: %0.1f%%\tLoss: %f\n",i, batches, nb_images, nb_images, accuracy*100, loss);
|
printf("\rBatch [%d/%d]\tImage [%d/%d]\tAccuracy: %0.1f%%\tLoss: %f\n",i, batches, nb_images, nb_images, accuracy*100, loss);
|
||||||
@ -262,10 +265,10 @@ int main(int argc, char* argv[]) {
|
|||||||
batches = strtol(argv[i+1], NULL, 10);
|
batches = strtol(argv[i+1], NULL, 10);
|
||||||
i += 2;
|
i += 2;
|
||||||
} else
|
} else
|
||||||
if ((! strcmp(argv[i], "--layers"))||(! strcmp(argv[i], "-c"))) {
|
if ((! strcmp(argv[i], "--couches"))||(! strcmp(argv[i], "-c"))) {
|
||||||
layers = strtol(argv[i+1], NULL, 10);
|
layers = strtol(argv[i+1], NULL, 10);
|
||||||
i += 2;
|
i += 2;
|
||||||
} else if ((! strcmp(argv[i], "--neurons"))||(! strcmp(argv[i], "-n"))) {
|
} else if ((! strcmp(argv[i], "--neurones"))||(! strcmp(argv[i], "-n"))) {
|
||||||
neurons = strtol(argv[i+1], NULL, 10);
|
neurons = strtol(argv[i+1], NULL, 10);
|
||||||
i += 2;
|
i += 2;
|
||||||
} else if ((! strcmp(argv[i], "--images"))||(! strcmp(argv[i], "-i"))) {
|
} else if ((! strcmp(argv[i], "--images"))||(! strcmp(argv[i], "-i"))) {
|
||||||
|
@ -57,7 +57,7 @@ void network_creation(Network* network, int* neurons_per_layer, int nb_layers) {
|
|||||||
for (int i=0; i < nb_layers; i++) {
|
for (int i=0; i < nb_layers; i++) {
|
||||||
network->layers[i] = (Layer*)malloc(sizeof(Layer));
|
network->layers[i] = (Layer*)malloc(sizeof(Layer));
|
||||||
layer = network->layers[i];
|
layer = network->layers[i];
|
||||||
layer->nb_neurons = neurons_per_layer[i]; // Nombre de neurones pour la layer
|
layer->nb_neurons = neurons_per_layer[i]; // Nombre de neurones pour la couche
|
||||||
layer->neurons = (Neuron**)malloc(sizeof(Neuron*)*network->layers[i]->nb_neurons); // Création des différents neurones dans la couche
|
layer->neurons = (Neuron**)malloc(sizeof(Neuron*)*network->layers[i]->nb_neurons); // Création des différents neurones dans la couche
|
||||||
|
|
||||||
for (int j=0; j < layer->nb_neurons; j++) {
|
for (int j=0; j < layer->nb_neurons; j++) {
|
||||||
@ -83,7 +83,7 @@ void deletion_of_network(Network* network) {
|
|||||||
|
|
||||||
for (int i=0; i<network->nb_layers; i++) {
|
for (int i=0; i<network->nb_layers; i++) {
|
||||||
layer = network->layers[i];
|
layer = network->layers[i];
|
||||||
if (i!=network->nb_layers-1) { // On exclut la dernière couche dont les neurons ne contiennent pas de poids sortants
|
if (i!=network->nb_layers-1) { // On exclut la dernière couche dont les neurones ne contiennent pas de poids sortants
|
||||||
for (int j=0; j<network->layers[i]->nb_neurons; j++) {
|
for (int j=0; j<network->layers[i]->nb_neurons; j++) {
|
||||||
neuron = layer->neurons[j];
|
neuron = layer->neurons[j];
|
||||||
free(neuron->weights);
|
free(neuron->weights);
|
||||||
@ -124,7 +124,7 @@ void forward_propagation(Network* network) {
|
|||||||
|
|
||||||
if (i < network->nb_layers-1) { // Pour toutes les couches sauf la dernière on utilise la fonction leaky_ReLU (a*z si z<0, z sinon)
|
if (i < network->nb_layers-1) { // Pour toutes les couches sauf la dernière on utilise la fonction leaky_ReLU (a*z si z<0, z sinon)
|
||||||
neuron->z = leaky_ReLU(neuron->z);
|
neuron->z = leaky_ReLU(neuron->z);
|
||||||
} else { // Pour la dernière layer on utilise la fonction sigmoid permettant d'obtenir un résultat entre 0 et 1 à savoir une probabilité
|
} else { // Pour la dernière couche on utilise la fonction softmax
|
||||||
max_z = max(max_z, neuron->z);
|
max_z = max(max_z, neuron->z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,16 +11,16 @@
|
|||||||
Contient un ensemble de fonctions utiles pour le débogage
|
Contient un ensemble de fonctions utiles pour le débogage
|
||||||
*/
|
*/
|
||||||
void help(char* call) {
|
void help(char* call) {
|
||||||
printf("Usage: %s ( print-poids | print-bias | creer-network ) [OPTIONS]\n\n", call);
|
printf("Usage: %s ( print-poids | print-biais | creer-reseau ) [OPTIONS]\n\n", call);
|
||||||
printf("OPTIONS:\n");
|
printf("OPTIONS:\n");
|
||||||
printf("\tprint-poids:\n");
|
printf("\tprint-poids:\n");
|
||||||
printf("\t\t--network | -r [FILENAME]\tFichier contenant le réseau de neurons.\n");
|
printf("\t\t--reseau | -r [FILENAME]\tFichier contenant le réseau de neurones.\n");
|
||||||
printf("\tprint-bias:\n");
|
printf("\tprint-biais:\n");
|
||||||
printf("\t\t--network | -r [FILENAME]\tFichier contenant le réseau de neurons.\n");
|
printf("\t\t--reseau | -r [FILENAME]\tFichier contenant le réseau de neurones.\n");
|
||||||
printf("\tcount-labels:\n");
|
printf("\tcount-labels:\n");
|
||||||
printf("\t\t--labels | -l [FILENAME]\tFichier contenant les labels.\n");
|
printf("\t\t--labels | -l [FILENAME]\tFichier contenant les labels.\n");
|
||||||
printf("\tcreer-network:\n");
|
printf("\tcreer-reseau:\n");
|
||||||
printf("\t\t--out | -o [FILENAME]\tFichier où écrire le réseau de neurons.\n");
|
printf("\t\t--out | -o [FILENAME]\tFichier où écrire le réseau de neurones.\n");
|
||||||
printf("\t\t--number | -n [int]\tNuméro à privilégier\n");
|
printf("\t\t--number | -n [int]\tNuméro à privilégier\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,9 +29,9 @@ void print_bias(char* filename) {
|
|||||||
Network* network = read_network(".cache/network.bin");
|
Network* network = read_network(".cache/network.bin");
|
||||||
|
|
||||||
for (int i=1; i < network->nb_layers -1; i++) {
|
for (int i=1; i < network->nb_layers -1; i++) {
|
||||||
printf("Layer %d\n", i);
|
printf("Couche %d\n", i);
|
||||||
for (int j=0; j < network->layers[i]->nb_neurons; j++) {
|
for (int j=0; j < network->layers[i]->nb_neurons; j++) {
|
||||||
printf("Layer %d\tNeuron %d\tBiais: %f\n", i, j, network->layers[i]->neurons[j]->bias);
|
printf("Couche %d\tNeurone %d\tBiais: %f\n", i, j, network->layers[i]->neurons[j]->bias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deletion_of_network(network);
|
deletion_of_network(network);
|
||||||
@ -41,9 +41,9 @@ void print_poids(char* filename) {
|
|||||||
Network* network = read_network(".cache/network.bin");
|
Network* network = read_network(".cache/network.bin");
|
||||||
|
|
||||||
for (int i=0; i < network->nb_layers -1; i++) {
|
for (int i=0; i < network->nb_layers -1; i++) {
|
||||||
printf("Layer %d\n", i);
|
printf("Couche %d\n", i);
|
||||||
for (int j=0; j < network->layers[i]->nb_neurons; j++) {
|
for (int j=0; j < network->layers[i]->nb_neurons; j++) {
|
||||||
printf("Layer %d\tNeuron %d\tPoids: [", i, j);
|
printf("Couche %d\tNeurone %d\tPoids: [", i, j);
|
||||||
for (int k=0; k < network->layers[i+1]->nb_neurons; k++) {
|
for (int k=0; k < network->layers[i+1]->nb_neurons; k++) {
|
||||||
printf("%f, ", network->layers[i]->neurons[j]->weights[k]);
|
printf("%f, ", network->layers[i]->neurons[j]->weights[k]);
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ int main(int argc, char* argv[]) {
|
|||||||
char* filename = NULL;
|
char* filename = NULL;
|
||||||
int i = 2;
|
int i = 2;
|
||||||
while (i < argc) {
|
while (i < argc) {
|
||||||
if ((! strcmp(argv[i], "--network"))||(! strcmp(argv[i], "-r"))) {
|
if ((! strcmp(argv[i], "--reseau"))||(! strcmp(argv[i], "-r"))) {
|
||||||
filename = argv[i+1];
|
filename = argv[i+1];
|
||||||
i += 2;
|
i += 2;
|
||||||
} else {
|
} else {
|
||||||
@ -142,11 +142,11 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
print_poids(filename);
|
print_poids(filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
} else if (! strcmp(argv[1], "print-bias")) {
|
} else if (! strcmp(argv[1], "print-biais")) {
|
||||||
char* filename = NULL;
|
char* filename = NULL;
|
||||||
int i = 2;
|
int i = 2;
|
||||||
while (i < argc) {
|
while (i < argc) {
|
||||||
if ((! strcmp(argv[i], "--network"))||(! strcmp(argv[i], "-r"))) {
|
if ((! strcmp(argv[i], "--reseau"))||(! strcmp(argv[i], "-r"))) {
|
||||||
filename = argv[i+1];
|
filename = argv[i+1];
|
||||||
i += 2;
|
i += 2;
|
||||||
} else {
|
} else {
|
||||||
@ -160,7 +160,7 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
print_bias(filename);
|
print_bias(filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
} else if (! strcmp(argv[1], "creer-network")) {
|
} else if (! strcmp(argv[1], "creer-reseau")) {
|
||||||
char* out = NULL;
|
char* out = NULL;
|
||||||
int n = -1;
|
int n = -1;
|
||||||
int i = 2;
|
int i = 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user