-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
71 lines (61 loc) · 2.05 KB
/
Copy pathmain.cpp
File metadata and controls
71 lines (61 loc) · 2.05 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "neuralNet.hpp"
int main()
{
std::vector<unsigned int> topology;
topology.push_back(2);
topology.push_back(4);
topology.push_back(1);
NeuralNet net(topology);
// Training Data
std::vector<double> inputVals, targetVals, resultVals;
inputVals.push_back(0);
inputVals.push_back(0);
targetVals.push_back(0);
int turn = 1;
// Train 0,0 is 0
// 1,1 is 1
for(int training = 0; training < 1000; training++)
{
switch (turn)
{
case 1:
inputVals[0] = 0.0;
inputVals[1] = 0.0;
targetVals[0] = 0.0;
net.feedForward(inputVals);
net.getResults(resultVals);
cout << "Pass: " << training << endl;
cout << "Input Vals: " << inputVals[0] <<","<< inputVals[1] <<endl;
cout << "Target: " << targetVals[0] << endl;
cout << "Result: " << resultVals[0] << endl;
net.backProp(targetVals);
// Report how well the training is working, average over recent samples:
cout << "Net recent average error: "
<< net.getRecentAverageError() << endl;
cout<<endl;
break;
case 2:
inputVals[0] = 1.0;
inputVals[1] = 1.0;
targetVals[0] = 1.0;
net.feedForward(inputVals);
net.getResults(resultVals);
cout << "Pass: " << training << endl;
cout << "Input Vals: " << inputVals[0] <<","<< inputVals[1] <<endl;
cout << "Target: " << targetVals[0] << endl;
cout << "Result: " << resultVals[0] << endl;
net.backProp(targetVals);
// Report how well the training is working, average over recent samples:
cout << "Net recent average error: "
<< net.getRecentAverageError() << endl;
cout<<endl;
break;
default:
break;
}
turn++;
if(turn > 2)
turn = 1;
}
return 0;
}