-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNeuralNetwork.h
44 lines (42 loc) · 941 Bytes
/
NeuralNetwork.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
#pragma once
#define BIAS 1.0
#define LEARNING_RATE 0.1
#define EMAX 0.001
#define CYCLE_MAX 30000
#define MOMENT_RATE 0.99
#define T_SIZE 2
struct Neuron
{
float net;
float output;
Neuron() { net = 0, output = 0; };
};
struct Layer
{
Neuron* neuron;
int neuron_size;
~Layer() {
delete[] neuron;
}
};
class ANN
{
public:
ANN();
~ANN();
void Init(const int h_layer_count, int* neuron_count, const int inputDim, const int numClass);
int TrainSGD(float* data, float* tag, int numSample);
int TrainSGDwMoment(float* data, float* tag, int numSample);
void Test(float* testData, int* tag, int DATASIZE); // It takes data array and predicts data tags-labels
void Test(float* testData, int& tag);
void SaveWeights();
void InitFromFile();
double* Error_arr;
private:
Layer* layer;
float** weights;
float** bias;
int LAYERCOUNT;// HIDDEN LAYER COUNT
int INPUTDIM; // INPUT DIMENSION
int NUMCLASS; // CLASS COUNT
};