From dffc1598fffa0158cb45cb4ec237afafe583d089 Mon Sep 17 00:00:00 2001 From: julienChemillier Date: Fri, 4 Nov 2022 08:31:58 +0100 Subject: [PATCH] Use of 'linearisation' variable --- src/cnn/creation.c | 6 ++++-- src/cnn/include/struct.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cnn/creation.c b/src/cnn/creation.c index 5228ad0..9e60c2b 100644 --- a/src/cnn/creation.c +++ b/src/cnn/creation.c @@ -29,8 +29,6 @@ Network* create_network(int max_size, int learning_rate, int dropout, int initia network->kernel[0]->nn = NULL; network->kernel[0]->cnn = NULL; create_a_cube_input_layer(network, 0, input_depth, input_dim); - // create_a_cube_input_z_layer(network, 0, input_depth, input_dim); - // This shouldn't be used (if I'm not mistaken) so to save space, we can do: network->input_z[0] = NULL; // As we don't backpropagate the input return network; } @@ -105,6 +103,7 @@ void add_2d_average_pooling(Network* network, int dim_output) { network->kernel[k_pos]->cnn = NULL; network->kernel[k_pos]->nn = NULL; network->kernel[k_pos]->activation = 100*kernel_size; // Ne contient pas de fonction d'activation + network->kernel[k_pos]->linearisation = 0; create_a_cube_input_layer(network, n, network->depth[n-1], network->width[n-1]/2); create_a_cube_input_z_layer(network, n, network->depth[n-1], network->width[n-1]/2); // Will it be used ? network->size++; @@ -124,6 +123,7 @@ void add_convolution(Network* network, int depth_output, int dim_output, int act int kernel_size = dim_input - dim_output +1; network->kernel[k_pos]->nn = NULL; network->kernel[k_pos]->activation = activation; + network->kernel[k_pos]->linearisation = 0; network->kernel[k_pos]->cnn = (Kernel_cnn*)malloc(sizeof(Kernel_cnn)); Kernel_cnn* cnn = network->kernel[k_pos]->cnn; @@ -179,6 +179,7 @@ void add_dense(Network* network, int output_units, int activation) { network->kernel[k_pos]->nn = (Kernel_nn*)malloc(sizeof(Kernel_nn)); Kernel_nn* nn = network->kernel[k_pos]->nn; network->kernel[k_pos]->activation = activation; + network->kernel[k_pos]->linearisation = 0; nn->input_units = input_units; nn->output_units = output_units; nn->bias = (float*)malloc(sizeof(float)*output_units); @@ -214,6 +215,7 @@ void add_dense_linearisation(Network* network, int output_units, int activation) network->kernel[k_pos]->nn = (Kernel_nn*)malloc(sizeof(Kernel_nn)); Kernel_nn* nn = network->kernel[k_pos]->nn; network->kernel[k_pos]->activation = activation; + network->kernel[k_pos]->linearisation = 1; nn->input_units = input_units; nn->output_units = output_units; diff --git a/src/cnn/include/struct.h b/src/cnn/include/struct.h index d8c6224..fb42c37 100644 --- a/src/cnn/include/struct.h +++ b/src/cnn/include/struct.h @@ -23,7 +23,7 @@ typedef struct Kernel_nn { typedef struct Kernel { Kernel_cnn* cnn; // NULL si ce n'est pas un cnn Kernel_nn* nn; // NULL si ce n'est pas un nn - int activation; // Vaut l'activation sauf pour un pooling où il: vaut pooling_size*100 + activation + int activation; // Vaut l'activation sauf pour un pooling où il: vaut pooling_size*100 int linearisation; // Vaut 1 si c'est la linéarisation d'une couche, 0 sinon ?? Ajouter dans les autres } Kernel;