-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
57 lines (51 loc) · 1.03 KB
/
Main.cpp
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
#include <iostream>
#include <Windows.h>
using namespace std;
#include "Neural Network/NeuralNetwork.h"
int main() {
//Initialize an array of layers
Layer Layers[] = {
Layer(2,2,"relu","nx"),
Layer(1,"relu")
};
//Initialize neural network
NN model(Layers, 2);
cout << "\n\n";
//Prepare data set
Matrix X(2, 4), Y(1, 4);
X.at(0, 0) = 0;
X.at(1, 0) = 0;
X.at(0, 1) = 1;
X.at(1, 1) = 0;
X.at(0, 2) = 0;
X.at(1, 2) = 1;
X.at(0, 3) = 1;
X.at(1, 3) = 1;
Y.at(0, 0) = 1;
Y.at(0, 1) = 1;
Y.at(0, 2) = 1;
Y.at(0, 3) = 0;
int epochs = 10000;
float learnRate = 0.05;
cout <<"X_train:\n"<< X <<"Y_train:\n" << Y<<endl;
//Train
model.train(X, Y, epochs, learnRate);
//Test
cout << "\nTesting:\n";
Matrix test;
test = X.Column(0);
cout << "Y0:";
model.test(test);
test = X.Column(1);
cout << "Y1:";
model.test(test);
test = X.Column(2);
cout << "Y2:";
model.test(test);
test = X.Column(3);
cout << "Y3:";
model.test(test);
cout << "\nExpected to be close to: " <<Y;
//Printing summary of model
model.summary();
}