-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayer.cpp
More file actions
executable file
·55 lines (51 loc) · 1.1 KB
/
layer.cpp
File metadata and controls
executable file
·55 lines (51 loc) · 1.1 KB
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
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdlib>
#include "nodes.cpp"
using namespace std;
class LAYER{
private:
double Net;
public:
double * Input;
NODE *Node;
int NodeLength;
int InputLength;
void FeedForward();
double Sigmoid(double Net);
double *OutputVector();
LAYER(int NoOfNodes,int NoOfInputs);
NODE * getNodes();
};
LAYER::LAYER(int NoOfNodes,int NoOfInputs){
Node=(NODE *)malloc(NoOfNodes*sizeof(NODE));
for(int i=0;i<NoOfNodes;i++){
Node[i]=NODE(NoOfInputs);
}
Input = new double[NoOfInputs];
NodeLength = NoOfNodes;
InputLength = NoOfInputs;
}
NODE * LAYER::getNodes(){
return Node;
}
double LAYER::Sigmoid(double Nit){
return 1.0/(1.0+exp(-Nit));
}
void LAYER::FeedForward(){
for(int i=0;i<NodeLength;i++){
Net = Node[i].Threshold;
for(int j=0;j<Node[i].WeightSize;j++){
Net += Node[i].Weight[j]*Input[j];
}
Node[i].Output = Sigmoid(Net);
}
}
double* LAYER::OutputVector(){
double * v = new double[NodeLength];
for(int i=0;i<NodeLength;i++)
v[i]=Node[i].Output;
return v;
}
//