From 3ad76cb0b8f2a75979a1c8e85ce1dd5f15c783c1 Mon Sep 17 00:00:00 2001 From: Martin Beseda <martin.beseda@vsb.cz> Date: Tue, 15 Jan 2019 16:10:36 +0100 Subject: [PATCH] ENH: Added example - evaluation of external data and saving of results into the other file. --- src/examples/simulator.cpp | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/examples/simulator.cpp b/src/examples/simulator.cpp index 684e2ef3..a4cbc2ef 100644 --- a/src/examples/simulator.cpp +++ b/src/examples/simulator.cpp @@ -156,24 +156,34 @@ int main(int argc, char** argv){ ds.de_normalize_single(expected_output_norm, expected_output); /* Evaluate network on an arbitrary data-set and save results into the file */ - l4n::DataSet ds2; - - std::vector<double> inp, out; - for(double i = 0; i < 5; i++) { - inp = {i}; - out = {i+2}; - - ds2.add_data_pair(inp, out); - } + l4n::CSVReader reader2("/home/martin/Desktop/vstup_pozadovany_vystup.txt", "\t"); + reader2.read(); + std::vector<unsigned int> inp_indices = {0}; + std::vector<unsigned int> out_indices = {1}; + l4n::DataSet ds2 = reader2.get_data_set(&inp_indices, &out_indices); + std::ofstream output_file_2("eval_output.txt"); + +// std::vector<double> inp, out; +// for(double i = 0; i < 5; i++) { +// inp = {i}; +// out = {i+2}; +// +// ds2.add_data_pair(inp, out); +// } - output_file << std::endl << "Evaluating network on the dataset: " << std::endl; - ds2.store_data_text(&output_file); +// output_file << std::endl << "Evaluating network on the dataset: " << std::endl; + output_file_2 << std::endl << "Evaluating network on the dataset: " << std::endl; +// ds2.store_data_text(&output_file); + ds2.store_data_text(&output_file_2); - output_file << "Output and the error:" << std::endl; - mse.eval_on_data_set(&ds2, &output_file); +// output_file << "Output and the error:" << std::endl; + output_file_2 << std::endl << "Evaluating network on the dataset: " << std::endl; +// mse.eval_on_data_set(&ds2, &output_file); + mse.eval_on_data_set(&ds2, &output_file_2); /* Close the output file for writing */ output_file.close(); + output_file_2.close(); return 0; -- GitLab