diff --git a/src/cnn/creation.c b/src/cnn/creation.c index d175870..a7858f0 100644 --- a/src/cnn/creation.c +++ b/src/cnn/creation.c @@ -33,7 +33,6 @@ Network* create_network(int max_size, float learning_rate, int dropout, int init network->width[0] = input_width; network->depth[0] = input_depth; create_a_cube_input_layer(network, 0, input_depth, input_width); - create_a_cube_input_z_layer(network, 0, input_depth, input_width); return network; } diff --git a/src/cnn/free.c b/src/cnn/free.c index f586c45..c66fca5 100644 --- a/src/cnn/free.c +++ b/src/cnn/free.c @@ -20,6 +20,16 @@ void free_a_cube_input_layer(Network* network, int pos, int depth, int dim) { gree(network->input_z[pos], true); } +void free_a_cube_input_layer_without_z(Network* network, int pos, int depth, int dim) { + for (int i=0; i < depth; i++) { + for (int j=0; j < dim; j++) { + gree(network->input[pos][i][j], true); + } + gree(network->input[pos][i], true); + } + gree(network->input[pos], true); +} + void free_a_line_input_layer(Network* network, int pos) { // Libère l'espace mémoire de network->input[pos] et network->input_z[pos] // lorsque ces couches sont denses (donc sont des matrice de dimension 1) @@ -97,7 +107,7 @@ void free_dense_linearisation(Network* network, int pos) { void free_network_creation(Network* network) { // On libère l'input correspondant à l'image: input[0] (car elle n'appartient à aucune couche) - free_a_cube_input_layer(network, 0, network->depth[0], network->width[0]); + free_a_cube_input_layer_without_z(network, 0, network->depth[0], network->width[0]); for (int i=0; i < network->max_size-1; i++) { gree(network->kernel[i], true); diff --git a/src/cnn/include/free.h b/src/cnn/include/free.h index be0a064..59a2bd5 100644 --- a/src/cnn/include/free.h +++ b/src/cnn/include/free.h @@ -10,6 +10,13 @@ */ void free_a_cube_input_layer(Network* network, int pos, int depth, int dim); +/* +* Libère l'espace mémoire de network->input[pos] +* lorsque cette couches est non denses (donc est une matrice de dimension 3) +* Libère donc l'espace mémoire alloué dans 'create_a_cube_input_layer' (creation.c) +*/ +void free_a_cube_input_layer_without_z(Network* network, int pos, int depth, int dim); + /* * Libère l'espace mémoire de network->input[pos] et network->input_z[pos] * lorsque ces couches sont denses (donc sont des matrice de dimension 1)