aboutsummaryrefslogtreecommitdiff
path: root/src/nn.c
diff options
context:
space:
mode:
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