Fix neuron_io

This commit is contained in:
augustin64 2023-01-17 17:01:16 +01:00
parent cea4132e2d
commit 4f946cf888
2 changed files with 12 additions and 5 deletions

View File

@ -14,12 +14,19 @@
void write_network(char* filename, Network* network) { void write_network(char* filename, Network* network) {
FILE *ptr; FILE *ptr;
int size = network->size; int size = network->size;
int type_couche[size]; int type_couche[size-1];
int indice_buffer = 0; int indice_buffer = 0;
ptr = fopen(filename, "wb"); 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(MAGIC_NUMBER);
bufferAdd(size); bufferAdd(size);
@ -160,9 +167,9 @@ Network* read_network(char* filename) {
} }
// Lecture du type de chaque couche // 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); fread(&tmp, sizeof(tmp), 1, ptr);
type_couche[i] = tmp; type_couche[i] = tmp;
} }

View File

@ -13,7 +13,7 @@
int main() { int main() {
printf("Création du réseau\n"); 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(GREEN "OK\n" RESET);
printf("Écriture du réseau\n"); printf("Écriture du réseau\n");