-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (28 loc) · 1009 Bytes
/
main.cpp
File metadata and controls
40 lines (28 loc) · 1009 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
#include <iostream>
#include "ml/Perceptron.h"
#include "ml/Trainer.h"
int main()
{
Trainer t = Trainer();
t.GenerateTestTrainingData();
Perceptron p = Perceptron(1, Perceptron::Linear);
int epoch = 100000;
std::vector<std::vector<float>> inputs = t.getInputs();
std::vector<float> outputs = t.getOutputs();
std::cout << p.toString() << std::endl;
float before = p.Evaluate(inputs, outputs);
for (int i = 0; i < epoch; i++)
{
p.Train(inputs, outputs, 0.001f);
}
float after = p.Evaluate(inputs, outputs);
std::cout << "Loss before : " << std::to_string(before) << std::endl;
std::cout << "Loss after (Training data) : " << std::to_string(after) << std::endl;
t.GenerateTestTestData();
inputs = t.getInputs();
outputs = t.getOutputs();
after = p.Evaluate(inputs, outputs);
std::cout << "Loss after : (Test data) " << std::to_string(after) << std::endl;
std::cout << p.toString() << std::endl;
return 0;
}