From 7fff1652c56bdc98b5b51de18f82e5facf552b5c Mon Sep 17 00:00:00 2001 From: augustin64 Date: Wed, 5 Oct 2022 11:28:29 +0200 Subject: [PATCH] Update neuron_io.c --- src/cnn/neuron_io.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/cnn/neuron_io.c b/src/cnn/neuron_io.c index 3e0e700..bf570e1 100644 --- a/src/cnn/neuron_io.c +++ b/src/cnn/neuron_io.c @@ -119,8 +119,6 @@ void write_couche(Kernel* kernel, int type_couche, FILE* ptr) { Network* read_network(char* filename) { FILE *ptr; Network* network = (Network*)malloc(sizeof(Network)); - // TODO: malloc pour network -> input - printf_warning("Chargement depuis un fichier, network->input ne sera pas alloué\n"); ptr = fopen(filename, "rb"); @@ -170,6 +168,20 @@ Network* read_network(char* filename) { for (int i=0; i < (int)size; i++) { network->kernel[i] = read_kernel(type_couche[i], ptr); } + + network->input = (float****)malloc(sizeof(float***)*size); + for (int i=0; i < size; i++) { // input[size][couche->depth][couche->dim][couche->dim] + network->input[i] = (float***)malloc(sizeof(float**)*network->depth[i]); + for (int j=0; j < network->depth[i]; j++) { + network->input[i][j] = (float**)malloc(sizeof(float*)*network->width[i]); + for (int k=0; k < network->width[i]; k++) { + network->input[i][j][k] = (float*)malloc(sizeof(float)*network->width[i]); + for (int l=0; l < network->width[i]; l++) { + network->input[i][j][k][l] = 0.; + } + } + } + } fclose(ptr); return network;