Commit 3f16d492 authored by Martin Beseda's avatar Martin Beseda
Browse files

FIX: Fixed Boost include dependencies, so the examples don't have to be...

FIX: Fixed Boost include dependencies, so the examples don't have to be compiled with Boost include directory.
parent 6d2a1bf7
......@@ -3,7 +3,7 @@
##############
# UNIT TESTS #
##############
for f in build/unit-tests/bin/*_test; do
for f in build/unit-tests/*_test; do
${f} || exit -1
done
......@@ -34,10 +34,6 @@ namespace boost {
template<class Archive>
void serialize(Archive & ar, DataSet & ds, const unsigned int version)
{
// ar & ds.n_elements;
// ar & ds.input_dim;
// ar & ds.output_dim;
// ar & ds.data;
DataSet::access::serialize(ar, ds, version);
}
......
......@@ -9,7 +9,6 @@
#define INC_4NEURO_CONNECTIONWEIGHTIDENTITY_H
#include "../settings.h"
#include "ConnectionFunctionGeneral.h"
class ConnectionFunctionGeneral;
......
......@@ -7,6 +7,19 @@
#include "NeuralNetwork.h"
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_real_distribution.hpp>
//#include <boost/archive/text_oarchive.hpp>
//#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/version.hpp>
#include <boost/serialization/split_member.hpp>
#include <boost/serialization/export.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/utility.hpp>
BOOST_CLASS_EXPORT(NeuronBinary);
BOOST_CLASS_EXPORT(NeuronConstant);
BOOST_CLASS_EXPORT(NeuronLinear);
......@@ -16,6 +29,47 @@ BOOST_CLASS_EXPORT(NeuronLogistic_d2);
BOOST_CLASS_EXPORT(ConnectionFunctionGeneral);
BOOST_CLASS_EXPORT(ConnectionFunctionIdentity);
struct NeuralNetwork :: access {
template <class Archive>
static void serialize(Archive &ar, NeuralNetwork& nn, const unsigned int version) {
ar & nn.neurons;
ar & nn.input_neuron_indices;
ar & nn.output_neuron_indices;
ar & nn.connection_list;
ar & nn.neuron_biases;
ar & nn.neuron_bias_indices;
ar & nn.neuron_potentials;
ar & nn.connection_weights;
ar & nn.inward_adjacency;
ar & nn.outward_adjacency;
ar & nn.neuron_layers_feedforward;
ar & nn.neuron_layers_feedbackward;
ar & nn.layers_analyzed;
ar & nn.delete_weights;
ar & nn.delete_biases;
}
};
namespace boost {
namespace serialization {
/**
* Serialization function
* @tparam Archive Boost library template
* @param ar Boost parameter - filled automatically during serialization!
* @param ds NeuralNetwork instance
* @param version Boost parameter - filled automatically during serialization!
*/
template<class Archive>
void serialize(Archive & ar, NeuralNetwork & nn, const unsigned int version)
{
NeuralNetwork::access::serialize(ar, nn, version);
}
} // namespace serialization
} // namespace boost
NeuralNetwork::NeuralNetwork() {
this->neurons = new std::vector<Neuron*>(0);
this->neuron_biases = new std::vector<double>(0);
......
......@@ -15,31 +15,43 @@
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <fstream>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_real_distribution.hpp>
//#include <boost/random/mersenne_twister.hpp>
//#include <boost/random/uniform_real_distribution.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/version.hpp>
#include <boost/serialization/split_member.hpp>
#include <boost/serialization/export.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/utility.hpp>
//#include <boost/serialization/list.hpp>
//#include <boost/serialization/string.hpp>
//#include <boost/serialization/version.hpp>
//#include <boost/serialization/split_member.hpp>
//#include <boost/serialization/export.hpp>
//#include <boost/serialization/vector.hpp>
//#include <boost/serialization/utility.hpp>
#include "../Neuron/Neuron.h"
#include "../Neuron/NeuronConstant.h"
#include "../Neuron/NeuronBinary.h"
#include "../Neuron/NeuronLinear.h"
//#include "../Neuron/NeuronLogistic.h" // ERROR
#include "../Neuron/NeuronLogistic.h"
#include "../NetConnection/ConnectionFunctionGeneral.h"
#include "../NetConnection/ConnectionFunctionIdentity.h"
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
enum class BIAS_TYPE{NEXT_BIAS, NO_BIAS, EXISTING_BIAS};
......@@ -52,7 +64,6 @@ enum class SIMPLE_CONNECTION_TYPE{NEXT_WEIGHT, UNITARY_WEIGHT, EXISTING_WEIGHT};
*/
class NeuralNetwork {
private:
friend class boost::serialization::access;
/**
*
......@@ -158,27 +169,13 @@ private:
*/
void analyze_layer_structure( );
template<class Archive>
void serialize(Archive & ar, const unsigned int version) {
ar & this->neurons;
ar & this->input_neuron_indices;
ar & this->output_neuron_indices;
ar & this->connection_list;
ar & this->neuron_biases;
ar & this-> neuron_bias_indices;
ar & this->neuron_potentials;
ar & this->connection_weights;
ar & this->inward_adjacency;
ar & this->outward_adjacency;
ar & this->neuron_layers_feedforward;
ar & this->neuron_layers_feedbackward;
ar & this->layers_analyzed;
ar & this->delete_weights;
ar & this->delete_biases;
};
public:
/**
*
*/
struct access;
/**
*
*/
......
......@@ -14,8 +14,6 @@
#include "Neuron.h"
#include "NeuronConstant.h"
#include <boost/serialization/base_object.hpp>
/**
* Linear neuron class - uses activation function in the form f(x)=a*x + b,
......
......@@ -10,6 +10,8 @@
#ifndef INC_4NEURO_NEURONLOGISTIC_H
#define INC_4NEURO_NEURONLOGISTIC_H
#include <boost/archive/text_oarchive.hpp>
#include "../settings.h"
#include <cmath>
......@@ -17,6 +19,9 @@
#include "../constants.h"
class NeuronLogistic:public Neuron, public IDifferentiable {
friend class boost::serialization::access;
......@@ -106,9 +111,6 @@ public:
};
class NeuronLogistic_d2:public NeuronLogistic_d1 {
private:
friend class boost::serialization::access;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment