From 8f776e61b2650486873516f903cb199e321e10f5 Mon Sep 17 00:00:00 2001 From: Soikk Date: Mon, 5 Sep 2022 14:31:44 +0200 Subject: Initial commit --- neural.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 neural.h (limited to 'neural.h') diff --git a/neural.h b/neural.h new file mode 100644 index 0000000..501055e --- /dev/null +++ b/neural.h @@ -0,0 +1,55 @@ +#pragma once +#ifndef NEURAL_H +#define NEURAL_H + +#define __MINGW_FEATURES__ 1 + +#include +#include +#include +#include +#include "../matrix/matrix.h" +#include "image/image.h" + + +typedef enum{ + LINEAR, RELU, SIGMOID, TANH, + //HE, XAVIER, +} FUNCTIONS; + +typedef struct layer{ + FUNCTIONS function; + int inputs; + int nneurons; + matrix *weights; + matrix *bias; + matrix *neurons; +} layer; + +typedef struct net{ + long double learningrate; + int inputs; + int outputs; + int nlayers; + matrix *input; + layer **layers; +} net; + +typedef long double (*func)(long double); + + +net *newNet(FUNCTIONS function, long double learningrate, int inputs, int outputs, int nlayers, ...); + +void saveNet(net *n, FILE *fp); + +net *loadNet(FILE *fp); + +matrix *propagate(net *n, matrix *input); + +void backPropagate(net *n, matrix *expected); + +void feedData(matrix *m, long double array[m->rows][m->cols]); + +matrix *imageToInput(image *im); + +#endif -- cgit v1.2.3