From 21ee3430c5147cb711be02ade1b10bf7004f4d71 Mon Sep 17 00:00:00 2001 From: julienChemillier Date: Sat, 11 Mar 2023 19:36:46 +0100 Subject: [PATCH] Update backpropation of max_pooling --- src/cnn/backpropagation.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cnn/backpropagation.c b/src/cnn/backpropagation.c index 8a89f59..b35bf94 100644 --- a/src/cnn/backpropagation.c +++ b/src/cnn/backpropagation.c @@ -72,11 +72,11 @@ void backward_max_pooling(float*** input, float*** output, int input_width, int m = input[i][size*j +a][size*k +b]; a_max = a; b_max = b; - input[i][size*j +a][size*k +b] = 0; } + input[i][size*j +a][size*k +b] = 0; } } - input[i][size*j +a_max][size*k +b_max] = output[i][j][k]; + input[i][size*j +a_max][size*k +b_max] = output[i][j][k]/(size*size); } } } @@ -146,10 +146,11 @@ void backward_linearisation(Kernel_nn* ker, float*** input, float*** input_z, fl void backward_convolution(Kernel_cnn* ker, float*** input, float*** input_z, float*** output, int depth_input, int dim_input, int depth_output, int dim_output, ptr d_function, int is_first) { // Bias + int n = dim_output*dim_output; for (int i=0; i < depth_output; i++) { for (int j=0; j < dim_output; j++) { for (int k=0; k < dim_output; k++) { - ker->d_bias[i][j][k] += output[i][j][k]; + ker->d_bias[i] += output[i][j][k]/n; } } }