forked from cryptixcoder/neural-ocr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNeuralNet.h
48 lines (38 loc) · 1.1 KB
/
NeuralNet.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
#include "Neuron.h"
#include "Layer.h"
class NeuralNet {
private:
int numInputs;
int numOutputs;
int numHiddenLayers;
int numNeuronsPerLayer;
double learningRate;
double responseThreshold;
std::vector<Layer*>* layers;
double* outputLayer;
public:
NeuralNet(int inputs,
int outputs,
int hiddenLayers,
int neuronsPerLayer,
double alpha,
double threshold);
~NeuralNet();
double* getWeights() const;
// Compute the outputs from a given set of inputs.
void feedForward(std::vector<double>* inputs,
std::vector<double>* outputLayer,
const double bias);
// Back propagate the errors to update the weights.
void backPropagate(std::vector<double>* outputs, int teacher);
// Sigmoid response function.
inline double sigmoid(double activation);
// Derivative of sigmoid response function.
inline double sigmoidPrime(double activation);
void print() {
for (int i = 1; i < layers->size(); i++) {
std::cout << "Layerr #" << i << "\n";
(*layers)[i]->printNeurons();
}
}
};