-
Notifications
You must be signed in to change notification settings - Fork 0
/
MlpNetwork.h
62 lines (51 loc) · 1.33 KB
/
MlpNetwork.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
//MlpNetwork.h
#ifndef MLPNETWORK_H
#define MLPNETWORK_H
#include "Dense.h"
#define MLP_SIZE 4
/**
* @struct digit
* @brief Identified (by Mlp network) digit with
* the associated probability.
* @var value - Identified digit value
* @var probability - identification probability
*/
typedef struct digit {
unsigned int value;
float probability;
} digit;
const matrix_dims img_dims = {28, 28};
const matrix_dims weights_dims[] = {{128, 784},
{64, 128},
{20, 64},
{10, 20}};
const matrix_dims bias_dims[] = {{128, 1},
{64, 1},
{20, 1},
{10, 1}};
/**
* @class MlpNetwork
* @brief This class represents the neural network
*/
class MlpNetwork
{
public:
// constructor
/**
* constructs the neural network
* @param weights Array of Matrices of the weights
* @param biases Array of Matrices of the biases
*/
MlpNetwork(Matrix weights[MLP_SIZE], Matrix biases[MLP_SIZE]);
// operator
/**
* Applies the entire network on input. returns digit struct.
* @param img Reference to Matrix object - an image
* @return digit struct containing the results
*/
digit operator () (const Matrix& img);
private:
Matrix _weights[MLP_SIZE]; // Array of weights of each layer
Matrix _biases[MLP_SIZE]; // Array of biases of each layer
};
#endif // MLPNETWORK_H