diff --git a/src/mnist/include/neuron.h b/src/mnist/include/neuron.h index 0478dbc..92556a9 100644 --- a/src/mnist/include/neuron.h +++ b/src/mnist/include/neuron.h @@ -1,7 +1,7 @@ #ifndef DEF_NEURON_H #define DEF_NEURON_H -typedef struct Neuron{ +typedef struct Neuron { float* weights; // Liste de tous les poids des arêtes sortants du neurone float bias; // Caractérise le bias du neurone float z; // Sauvegarde des calculs faits sur le neurone (programmation dynamique) @@ -13,12 +13,12 @@ typedef struct Neuron{ } Neuron; -typedef struct Layer{ +typedef struct Layer { int nb_neurons; // Nombre de neurones dans la couche (longueur du tableau ci-dessous) Neuron** neurons; // Tableau des neurones dans la couche } Layer; -typedef struct Network{ +typedef struct Network { int nb_layers; // Nombre de couches dans le réseau neuronal (longueur du tableau ci-dessous) Layer** layers; // Tableau des couches dans le réseau neuronal } Network; diff --git a/src/mnist/mnist.c b/src/mnist/mnist.c index 12863d7..8edabb8 100644 --- a/src/mnist/mnist.c +++ b/src/mnist/mnist.c @@ -19,9 +19,9 @@ int** read_image(unsigned int width, unsigned int height, FILE* ptr) { fread(buffer, sizeof(buffer), 1, ptr); - for (int i=0; ilast_back_bias = 0.0; neuron->back_bias = 0.0; - float* weights = malloc(sizeof(float)*nb_weights); + float* weights = (float*)malloc(sizeof(float)*nb_weights); - neuron->last_back_weights = malloc(sizeof(float)*nb_weights); - neuron->back_weights = malloc(sizeof(float)*nb_weights); + neuron->last_back_weights = (float*)malloc(sizeof(float)*nb_weights); + neuron->back_weights = (float*)malloc(sizeof(float)*nb_weights); neuron->weights = weights; - for (int i=0; i < nb_weights; i++) { + for (int i=0; i < (int)nb_weights; i++) { fread(&tmp, sizeof(float), 1, ptr); neuron->weights[i] = tmp; neuron->back_weights[i] = 0.0; @@ -42,8 +42,8 @@ Neuron* read_neuron(uint32_t nb_weights, FILE *ptr) { // Lit une couche de neurones Neuron** read_neurons(uint32_t nb_neurons, uint32_t nb_weights, FILE *ptr) { - Neuron** neurons = malloc(sizeof(Neuron*)*nb_neurons); - for (int i=0; i < nb_neurons; i++) { + Neuron** neurons = (Neuron**)malloc(sizeof(Neuron*)*nb_neurons); + for (int i=0; i < (int)nb_neurons; i++) { neurons[i] = read_neuron(nb_weights, ptr); } return neurons; @@ -53,7 +53,7 @@ Neuron** read_neurons(uint32_t nb_neurons, uint32_t nb_weights, FILE *ptr) { // Charge l'entièreté du réseau neuronal depuis un fichier binaire Network* read_network(char* filename) { FILE *ptr; - Network* network = malloc(sizeof(Network)); + Network* network = (Network*)malloc(sizeof(Network)); ptr = fopen(filename, "rb"); @@ -71,20 +71,20 @@ Network* read_network(char* filename) { network->nb_layers = nb_layers; - Layer** layers = malloc(sizeof(Layer*)*nb_layers); + Layer** layers = (Layer**)malloc(sizeof(Layer*)*nb_layers); uint32_t nb_neurons_layer[nb_layers+1]; - network->layers = layers; + network->layers = layers; - for (int i=0; i < nb_layers; i++) { - layers[i] = malloc(sizeof(Layer)); + for (int i=0; i < (int)nb_layers; i++) { + layers[i] = (Layer*)malloc(sizeof(Layer)); fread(&tmp, sizeof(tmp), 1, ptr); layers[i]->nb_neurons = tmp; nb_neurons_layer[i] = tmp; } nb_neurons_layer[nb_layers] = 0; - for (int i=0; i < nb_layers; i++) { + for (int i=0; i < (int)nb_layers; i++) { layers[i]->neurons = read_neurons(layers[i]->nb_neurons, nb_neurons_layer[i+1], ptr); } @@ -136,4 +136,4 @@ int write_network(char* filename, Network* network) { fclose(ptr); return 1; -} \ No newline at end of file +}