From b21ac2367380b4549b0f243d2e12197911a4b1b0 Mon Sep 17 00:00:00 2001 From: julienChemillier Date: Fri, 4 Nov 2022 12:02:00 +0100 Subject: [PATCH] Add of the dropout feature --- src/cnn/cnn.c | 17 +++++++++++++++++ src/cnn/include/cnn.h | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/src/cnn/cnn.c b/src/cnn/cnn.c index 19f7b35..ade10ea 100644 --- a/src/cnn/cnn.c +++ b/src/cnn/cnn.c @@ -57,6 +57,12 @@ void forward_propagation(Network* network) { output_width = network->width[i+1]; activation = k_i->activation; + if (k_i->nn) { + drop_neurones(input, 1, 1, input_width, network->dropout); + } else { + drop_neurones(input, input_depth, input_width, input_width, network->dropout); + } + if (k_i->cnn) { // Convolution make_convolution(k_i->cnn, input, output, output_width); copy_input_to_input_z(output, output_a, output_depth, output_width, output_width); @@ -125,6 +131,17 @@ void backward_propagation(Network* network, float wanted_number) { free(wanted_output); } +void drop_neurones(float*** input, int depth, int dim1, int dim2, int dropout) { + for (int i=0; i