-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (45 loc) · 977 Bytes
/
main.cpp
File metadata and controls
59 lines (45 loc) · 977 Bytes
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
#include <iostream>
#include "lib/ZZNetwork.h"
using namespace std;
int main() {
int sizes[] = {2, 4, 1};
int nbLayers = 3;
double **X = new double*[1000];
double **Y = new double*[1000];
for(int i = 0; i < 1000; i++)
{
X[i] = new double[2];
Y[i] = new double[2];
}
for(int i = 0; i < 250; i++)
{
X[i][0] = 0.0;
X[i][1] = 0.0;
Y[i][0] = 1.0;
}
for(int i = 250; i < 500; i++)
{
X[i][0] = 1.0;
X[i][1] = 0.0;
Y[i][0] = 0.0;
}
for(int i = 500; i < 750; i++)
{
X[i][0] = 0.0;
X[i][1] = 1.0;
Y[i][0] = 0.0;
}
for(int i = 750; i < 1000; i++)
{
X[i][0] = 1.0;
X[i][1] = 1.0;
Y[i][0] = 1.0;
}
ZZNetwork notNet(sizes, nbLayers, 1000, X, Y);
notNet.train();
cout << "xnor(0, 0) = " << notNet.predict(X[0])[0] << endl;
cout << "xnor(1, 0) = " << notNet.predict(X[300])[0] << endl;
cout << "xnor(0, 1) = " << notNet.predict(X[600])[0] << endl;
cout << "xnor(1, 1) = " << notNet.predict(X[900])[0] << endl;
return 0;
}