-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrainingData.cpp
67 lines (54 loc) · 1.36 KB
/
TrainingData.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
58
59
60
61
62
63
64
65
66
67
#include "TrainingData.h"
TrainingData::TrainingData(const std::string filename)
{
m_trainingDataFile.open(filename.c_str());
}
void TrainingData::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 TrainingData::getNextInputs(std::vector<double> &inputVals)
{
inputVals.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) {
inputVals.push_back(oneValue);
}
}
return inputVals.size();
}
unsigned TrainingData::getTargetOutputs(std::vector<double> &targetOutputVals)
{
targetOutputVals.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) {
targetOutputVals.push_back(oneValue);
}
}
return targetOutputVals.size();
}