summaryrefslogtreecommitdiff
path: root/neural.h
diff options
context:
space:
mode:
authorSoikk2022-09-05 14:31:44 +0200
committerSoikk2022-09-05 14:31:44 +0200
commit8f776e61b2650486873516f903cb199e321e10f5 (patch)
tree8861c2b375abb45ea0752debd46d8e79e29d7152 /neural.h
downloadsoikk-neural-net-8f776e61b2650486873516f903cb199e321e10f5.tar.xz
soikk-neural-net-8f776e61b2650486873516f903cb199e321e10f5.tar.zst
Initial commit
Diffstat (limited to 'neural.h')
-rw-r--r--neural.h55
1 files changed, 55 insertions, 0 deletions
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 <math.h>
+#include <time.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#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