-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNeuralNetwork.hpp
41 lines (35 loc) · 963 Bytes
/
NeuralNetwork.hpp
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
#include <cstdio>
#include <vector>
#include "Matrix.hpp"
using namespace std;
class NeuralNetwork {
Matrix *L;
Matrix *W;
int layersLength;
int weightsLength;
Matrix *deltas;
Matrix lastError;
public:
NeuralNetwork(vector<int>);
~NeuralNetwork();
vector<double> guess(vector<double>);
/**
* pair.first -> input layer as Matrix
* |
* -> length = neurons in input layer and cols in input matrix
* -> width = number of data sets and rows in input matrix
*
* pair.second -> output layer as Matrix
* |
* -> length = expected result in output and cols in input matrix
* -> width = number of data sets and rows in input matrix
*
* Rows and columns are flipped so as to avoid transposing when multiplying
*/
void train(pair<Matrix, Matrix>, int);
void printLayers();
void printWeights();
private:
void feedforward();
void backpropagation(Matrix);
};