Skip to content
Snippets Groups Projects
Commit 6fe99473 authored by rtalbi's avatar rtalbi
Browse files

non-privacy presrerving neural networks (finished code, started debug)

parent 64b78c68
No related branches found
No related tags found
No related merge requests found
...@@ -221,34 +221,67 @@ void NN::train () // ...@@ -221,34 +221,67 @@ void NN::train () //
} }
//todo : transform this method so that prediction happens for fa test batch
void NN::Test( ){ void NN::Test( ){
int counter =0; int counter =0;
int recordCounter = 0;
int size= dt->test_size; int size= dt->test_size;
Record * record; Record * record;
vector<Record*> XB;
int label; int label;
int sizeBatch=batchSize;
std::ofstream classOutput; std::ofstream classOutput;
classOutput.open (logfile); classOutput.open (logfile);
extTestBd = 0; extTestBd = 0;
auto begin = chrono::high_resolution_clock::now(); auto begin = chrono::high_resolution_clock::now();
while (counter < size) { while (counter < size) {
counter++; if (size - counter < batchSize)
sizeBatch = size - counter;
label = predict(record,true);
if(classOutput.is_open()) for (recordCounter = 0; recordCounter < sizeBatch; recordCounter++) {
{ try {
classOutput<<label<< endl;
record = dt->getTrainRecord();
XB.push_back(record);
extTrainBd += record->values.size() + 1;
counter++;
}
catch (std::exception const &e) {
cout << e.what() << endl;
}
}
vector<int> prediction = predict(XB, true);
for (int k=0; k < prediction.size();k++) {
int label = prediction[k];
if (classOutput.is_open()) {
classOutput << label << endl;
}
}
for (int i = 0; i < XB.size(); i++) {
delete XB[i];
} }
delete record;
XB.clear();
} }
auto end = chrono::high_resolution_clock::now(); auto end = chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> duration = end - begin ; std::chrono::duration<double, std::milli> duration = end - begin ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment