diff options
author | jvech <jmvalenciae@unal.edu.co> | 2023-08-05 20:53:28 -0500 |
---|---|---|
committer | jvech <jmvalenciae@unal.edu.co> | 2023-08-05 20:53:28 -0500 |
commit | 1ec97406e56b0668f035948203e2fe8e7c230dc7 (patch) | |
tree | d1d7351a40288d560aadfe0ea070b9b9cd9cec15 /src/nn.c | |
parent | 179613cd790ddf87c3fc501b346f242d17065917 (diff) |
add: nn_backward() calloc error handling added
Diffstat (limited to 'src/nn.c')
-rw-r--r-- | src/nn.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -19,6 +19,8 @@ void nn_backward( double *delta = calloc(max_neurons, sizeof(double)); double *delta_next = calloc(max_neurons, sizeof(double)); + if (!dcost_out || !delta || !delta_next) goto nn_backward_error; + for (size_t i = 0; i < labels_shape[0]; i++) { for (size_t j = 0; j < labels_shape[0]; j++) { size_t index = i * labels_shape[1] + j; @@ -55,6 +57,10 @@ void nn_backward( free(dcost_out); free(delta); free(delta_next); + +nn_backward_error: + perror("nn_backward() Error"); + exit(1); } void nn_layer_backward( |