-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeTrainingSamples.cc
66 lines (55 loc) · 1.79 KB
/
makeTrainingSamples.cc
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
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
int main(){
cout <<"topology: 1000 400 50 1" << endl;
vector< vector<double> > dataset;
int numimatges = 26;
for(int i = 0; i < numimatges; ++i){
dataset.push_back(vector<double> ());
ifstream m_trainingDataFile;
string filename = "./no/input"+to_string(i)+".txt";
m_trainingDataFile.open(filename.c_str());
string line;
getline(m_trainingDataFile, line);
stringstream ss(line);
double label;
while (ss >> label) {
dataset.back().push_back(label);
}
dataset.back().push_back(-1.0);
for(int f = 0; f < 50; ++f){
dataset.push_back(dataset.back());
}
}
int numimatgesbones = 26;
for(int i = 0; i < numimatgesbones; ++i){
dataset.push_back(vector<double> ());
ifstream m_trainingDataFile;
string filename = "./si/input"+to_string(i)+".txt";
m_trainingDataFile.open(filename.c_str());
string line;
getline(m_trainingDataFile, line);
stringstream ss(line);
double label;
while (ss >> label) {
dataset.back().push_back(label);
}
dataset.back().push_back(1.0);
for(int f = 0; f < 50; ++f){
dataset.push_back(dataset.back());
}
}
random_shuffle( dataset.begin(),dataset.end() );
for (int i = 0; i < dataset.size(); ++i){
cout << "in: " ;
for(int j = 0; j < dataset[i].size()-1 ; ++j) cout << dataset[i][j] << " " ;
cout << endl << "out: " << dataset[i].back() <<endl;
}
}