-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmlp.h
72 lines (53 loc) · 1.42 KB
/
mlp.h
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
_____ __ _____
| | | | _ |
| | | | |__| __|
|_|_|_|_____|__| C++11 Standard
Multilayer perceptron (MLP) with backpropagation
A simple implementation of artificial neural network
Written by Emilio Schinina' ([email protected])
File: mlp.h
*/
#ifndef _MLP_H_
#define _MLP_H_
#include "matrix.h"
#include "utils.h"
#include <vector>
#include <math.h>
#define _DEBUG_MLP_ false
#define _DEBUG_W_ true
#define _LEARNING_RATE_W_ 0.1
#define _LEARNING_RATE_B_ 0.06
#define _MAX_ITERATION_ 300000
#define _TOLLERANCE_ 1.0E-20
#define _MAX_RAND_W_ 2 // TANH limit
#define _MAX_RAND_B_ 2 // TANH limit
class mlp {
public:
// matrice con il numero di nodi per ogni hidden layer
// TODO: matrix.cpp add file2matrix()
mlp(int, int , int, int);
~mlp();
double learn(matrix, matrix); // deve ritornare il valore di errore
matrix solve(matrix);
matrix matrixsigmoid(matrix b);
matrix matrixsigmoidderivative(matrix);
// bool load(char* filename);
// bool save(const mlp& source);
private:
matrix structure;
int _NUM_LAYER_;
int _NUM_NODE_; // deve cambiare da matrice in matrice
int _NUM_INPUT_;
int _NUM_OUTPUT_;
// cambiare oggetto vettore
std::vector<matrix> weight;
std::vector<matrix> bias;
std::vector<matrix> H;
std::vector<matrix> Z;
std::vector<matrix> dNETpi_dW;
std::vector<matrix> dOpi_dNETpi;
std::vector<matrix> dE_dOpi;
std::vector<matrix> gradient; // dE_dw
};
#endif /* _MLP_H_ */