-
Notifications
You must be signed in to change notification settings - Fork 1
/
trainingData.cpp
56 lines (43 loc) · 1.16 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
#include "trainingData.h"
TrainingData::TrainingData(const string filename) {
mDataFile.open(filename.c_str());
}
void TrainingData::getTopology(vector<unsigned int>& topology) {
string line, label;
getline(mDataFile, line);
stringstream stream(line);
stream >> label;
if(this->isEoF() || label.compare("topology:") != 0)
abort();
int tmp;
while(!stream.eof()) {
stream >> tmp;
topology.push_back(tmp);
}
}
int TrainingData::getNextInputs(vector<double>& inputVals) {
inputVals.clear();
string line, label;
getline(mDataFile, line);
stringstream stream(line);
stream >> label;
if(label.compare("in:") == 0) {
double tmp;
while(stream >> tmp)
inputVals.push_back(tmp);
}
return inputVals.size();
}
int TrainingData::getTargetOutputs(vector<double>& targetVals) {
targetVals.clear();
string line, label;
getline(mDataFile, line);
stringstream stream(line);
stream >> label;
if(label.compare("out:") == 0) {
double tmp;
while(stream >> tmp)
targetVals.push_back(tmp);
}
return targetVals.size();
}