-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestingFile.cpp
More file actions
59 lines (44 loc) · 1.53 KB
/
TestingFile.cpp
File metadata and controls
59 lines (44 loc) · 1.53 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
#include <string>
#include <iostream>
#include <vector>
#include <thread>
#include <chrono>
#include <memory>
#include "Architecture.hpp"
#include "ActivationFunctions.hpp"
#include "Layers.hpp"
#include "Basic.hpp"
#include "Loss.hpp"
#include "Optimizer.hpp"
int main() {
std::vector<std::shared_ptr<NetComponent>> layers;
layers.push_back(std::make_shared<LinearLayer>(1, 2));
layers.push_back(std::make_shared<LeakyRelu>());
layers.push_back(std::make_shared<LinearLayer>(2, 1));
Model model(layers);
L2Loss loss_fn;
Adam optim(&model, 0.01);
model.load_net("net_test", true);
model.print_net();
// std::vector<float> targets;
// for (int i = 0; i < 10; i++){
// targets.push_back(i*2 + 1);
// }
// std::vector<float> prediction;
// for (int x = 0; x < 600; x++){
// for (int i = 0; i < targets.size(); i++){
// prediction = model.run({(float)i});
// loss_fn.calculate(prediction, {targets[i]});
// model.backprop(loss_fn.derivative());
// optim.apply_changes(0.5);
// }
// }
// for (int i = 0; i < targets.size(); i++){
// prediction = model.run({(float)i});
// std::cout << "Prediction: " << prediction[0] << ", Target:" << targets[i] << ", Loss:" << loss_fn.calculate(prediction, {targets[i]}) << std::endl;
// model.backprop(loss_fn.derivative());
// optim.apply_changes(0.5);
// }
std::this_thread::sleep_for(std::chrono::seconds(100));
return 0;
}