aboutsummaryrefslogtreecommitdiff
path: root/src/nn.h
blob: fb495bd0e851287b9e59ae8e6c6e3b351b8b1583 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef __NN__
#define __NN__

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <unistd.h>

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
Feel free to download, copy and edit any repo