-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
51 lines (42 loc) · 926 Bytes
/
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
#include <iostream>
#include <chrono>
#include "macro.hpp"
#include "NeuralNetwork.h"
//#define SAVE
using namespace math;
using namespace std;
using namespace chrono;
int main()
{
try
{
GC_DEBUG;
srand(time(NULL));
#ifdef SAVE
unsigned int layers[3] = { 4, 4, 4 };
NeuralNetwork nn(4, 4, layers, 3);
vector<Vector> vectors(100);
for_in_range(i, 0, 50)
{
for_in_range(j, 0, 100)
vectors[j] = Vector::random(4);
nn.learn(vectors, vectors);
cout << "Average cost after " << i + 1 << " batches learned: " << nn.averageCost(vectors, vectors) << endl;
}
nn.save("test.nn");
#else
NeuralNetwork nn("test.nn");
vector<Vector> vectors(100);
for_in_range(j, 0, 100)
vectors[j] = Vector::random(4);
cout << "Average cost: " << nn.averageCost(vectors, vectors) << endl;
nn.save("test1.nn");
#endif
return 0;
}
catch (exception e)
{
cout << e.what() << endl;
return -1;
}
}