aboutsummaryrefslogtreecommitdiff
path: root/src/nn.c
diff options
context:
space:
mode:
authorjvech <jmvalenciae@unal.edu.co>2023-08-05 20:53:28 -0500
committerjvech <jmvalenciae@unal.edu.co>2023-08-05 20:53:28 -0500
commit1ec97406e56b0668f035948203e2fe8e7c230dc7 (patch)
treed1d7351a40288d560aadfe0ea070b9b9cd9cec15 /src/nn.c
parent179613cd790ddf87c3fc501b346f242d17065917 (diff)
add: nn_backward() calloc error handling added
Diffstat (limited to 'src/nn.c')
-rw-r--r--src/nn.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nn.c b/src/nn.c
index 83fd77a..7744fd4 100644
--- a/src/nn.c
+++ b/src/nn.c
@@ -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(
Feel free to download, copy and edit any repo