-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrainingDriver.cpp
More file actions
72 lines (57 loc) · 1.45 KB
/
trainingDriver.cpp
File metadata and controls
72 lines (57 loc) · 1.45 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
60
61
62
63
64
65
66
67
68
69
70
71
//
// Created by Eugene Baek on 2021-04-16.
//
#include "trainingDriver.hpp"
TrainingDriver::TrainingDriver(const std::string filename)
{
m_trainingDataFile.open(filename.c_str());
}
void TrainingDriver::getTopology(std::vector<unsigned> &topology)
{
std::string line;
std::string label;
getline(m_trainingDataFile, line);
std::stringstream ss(line);
ss >> label;
if (this->isEof() || label.compare("topology:") != 0) {
abort();
}
while (!ss.eof()) {
unsigned n;
ss >> n;
topology.push_back(n);
}
return;
}
unsigned TrainingDriver::getNextInputs(std::vector<double> &input_values)
{
input_values.clear();
std::string line;
getline(m_trainingDataFile, line);
std::stringstream ss(line);
std::string label;
ss>> label;
if (label.compare("in:") == 0) {
double oneValue;
while (ss >> oneValue) {
input_values.push_back(oneValue);
}
}
return input_values.size();
}
unsigned TrainingDriver::getTargetOutputs(std::vector<double> &target_output_values)
{
target_output_values.clear();
std::string line;
getline(m_trainingDataFile, line);
std::stringstream ss(line);
std::string label;
ss>> label;
if (label.compare("out:") == 0) {
double oneValue;
while (ss >> oneValue) {
target_output_values.push_back(oneValue);
}
}
return target_output_values.size();
}