diff --git a/src/cnn/neuron_io.c b/src/cnn/neuron_io.c index fa6935b..4d1948d 100644 --- a/src/cnn/neuron_io.c +++ b/src/cnn/neuron_io.c @@ -14,12 +14,19 @@ void write_network(char* filename, Network* network) { FILE *ptr; int size = network->size; - int type_couche[size]; + int type_couche[size-1]; int indice_buffer = 0; ptr = fopen(filename, "wb"); - uint32_t buffer[(network->size)*3+4]; + // Le buffer est composé de: + // - MAGIC_NUMBER (1) + // - size (2) + // - network->initialisation (3) + // - network->dropout (4) + // - network->width[i] & network->depth[i] (4+network->size*2) + // - type_couche[i] (3+network->size*3) - On exclue la dernière couche + uint32_t buffer[(network->size)*3+3]; bufferAdd(MAGIC_NUMBER); bufferAdd(size); @@ -160,9 +167,9 @@ Network* read_network(char* filename) { } // Lecture du type de chaque couche - uint32_t type_couche[size]; + uint32_t type_couche[size-1]; - for (int i=0; i < (int)size; i++) { + for (int i=0; i < (int)size-1; i++) { fread(&tmp, sizeof(tmp), 1, ptr); type_couche[i] = tmp; } diff --git a/test/cnn_neuron_io.c b/test/cnn_neuron_io.c index aa6e9d1..e457841 100644 --- a/test/cnn_neuron_io.c +++ b/test/cnn_neuron_io.c @@ -13,7 +13,7 @@ int main() { printf("Création du réseau\n"); - Network* network = create_network_lenet5(0, 0, 3, 2, 32, 1); + Network* network = create_network_lenet5(0, 0, 3, GLOROT, 32, 1); printf(GREEN "OK\n" RESET); printf("Écriture du réseau\n");