summaryrefslogtreecommitdiff
path: root/neural.h
blob: 501055e60bdc5311319cb557e04cdc5019961516 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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