From 46f8c9bed801355ecd85c14ea7a7f11d38f1e5ba Mon Sep 17 00:00:00 2001 From: jvech Date: Wed, 12 Jul 2023 10:50:32 -0500 Subject: add: weights initialization and deallocation done --- src/nn.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/nn.h (limited to 'src/nn.h') diff --git a/src/nn.h b/src/nn.h new file mode 100644 index 0000000..fb495bd --- /dev/null +++ b/src/nn.h @@ -0,0 +1,24 @@ +#ifndef __NN__ +#define __NN__ + +#include +#include +#include +#include +#include + +typedef struct Layer { + double *weights, *bias; + double (*activation)(double x); + size_t neurons, input_size; +} Layer; + +void nn_layer_init_weights(Layer *layer, size_t nmemb, size_t input_size); +void nn_layer_free_weights(Layer *layer, size_t nmemb); + +double * nn_layer_forward(Layer layer, double *input, size_t input_shape[2]); +double * nn_layer_backward(Layer layer, double *output, size_t out_shape[2]); + +double sigmoid(double x); +double relu(double x); +#endif -- cgit v1.2.3-70-g09d2