Skip to content
Snippets Groups Projects
Commit d8845f07 authored by Martin Beseda's avatar Martin Beseda
Browse files

ENH: Added DataSet serialization example

parent 3b5fbcef
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,8 @@
#include <iostream>
#include <cstdio>
#include <fstream>
#include <vector>
#include <utility>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include "Network/NeuralNetwork.h"
......@@ -19,6 +21,7 @@
#include "LearningMethods/ParticleSwarm.h"
#include "Neuron/NeuronBinary.h"
#include "Neuron/NeuronTanh.h"
#include "DataSet/DataSet.h"
//TODO prepsat tak, aby neuronova sit managovala destruktory vsech potrebnych objektu (kvuli serializaci)
/**
......@@ -171,6 +174,31 @@ void test2() {
<< n8.activation_function_get_parameter(0) << std::endl;
}
/**
* Test of DataSet serialization
*/
void test3() {
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
std::vector<double> inp, out;
for(int i = 0; i < 3; i++) {
inp.push_back(i);
out.push_back(i+4);
}
data_vec.emplace_back(std::make_pair(inp, out));
DataSet ds(&data_vec);
ds.print_data();
ds.store_text("stored_data.4ds");
DataSet ds2("stored_data.4ds");
ds2.print_data();
}
double particle_swarm_test_function(double *x){
// return x[0] * x[1] - x[0] * x[0] + x[1] * x[2];
return x[0] * x[0];
......@@ -311,9 +339,11 @@ int main(int argc, char** argv){
// test_particle_swarm();
test_particle_swarm_neural_net();
// test_particle_swarm_neural_net();
// test2();
test2();
test3();
return 0;
}
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