-
Notifications
You must be signed in to change notification settings - Fork 0
/
NNet.h
86 lines (78 loc) · 1.42 KB
/
NNet.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef _NNET_H_
#define _NNET_H_
using namespace std;
class node
{
public:
double value,di;
int layer;
public:
double activF(double);
double getValue();
double getDi();
void setLayer(int);
};
class connect
{
public:
node *conNode;
double *conWeight;
double getWeight();
};
class oNode:public node
{
public:
connect inCon[50];
int numIn;
double bias;
public:
void calValue();
void setInNode(int num, connect cont[]);
void updateDi(double);
};
class ierNode: public node
{
public:
connect inCon[50],outCon[50];
int numIn,numOut;
double bias;
public:
void calValue();
void setInNode(int num, connect cont[]);
void setOutNode(int num, connect cont[]);
void updateDi(double);
int numO();
};
class inNode:public node
{
public:
connect outCon[50];
int numOut,numInput;
double input;
public:
void setInput(double in); //set the input of this input node
void calValue();
void setOutNode(int num, connect cont[]);
};
class nNet
{
public:
double weight[10][50][50],alpha;
inNode inN[50];
ierNode ierN[10][50];
oNode oN;
int strucL[10],numLayer;
void initNode(int,int[]);
void initWeight(int,int[],double);
void initWeight(int,int[]);
double calOutput(double[]);
void displayValue();
void setAlpha(double a);
void learn(double[],double);
double calErr(double[],double);
double calErr(double,double);
void displayWeight(char[]);
bool saveWeight(char [], double accur);
bool loadWeight(char []);
};
#endif