serializatioin / deserialization and tests
This commit is contained in:
@@ -40,6 +40,15 @@ namespace Recurrent {
|
||||
}
|
||||
};
|
||||
|
||||
Network(const Network &r) :inputSize(r.inputSize), outputSize(r.outputSize), neurons(0), outputs(r.outputs) {
|
||||
neurons.push_back(new NeuralNetwork::BiasNeuron());
|
||||
for(std::size_t i=1;i<r.neurons.size();i++) {
|
||||
neurons.push_back(r.neurons[i]->clone());
|
||||
}
|
||||
}
|
||||
|
||||
Network& operator=(const Network&r);
|
||||
|
||||
/**
|
||||
* @brief Virtual destructor for Network
|
||||
*/
|
||||
@@ -70,9 +79,7 @@ namespace Recurrent {
|
||||
return neurons;
|
||||
}
|
||||
|
||||
using NeuralNetwork::Network::stringify;
|
||||
|
||||
void stringify(std::ostream& out) const override;
|
||||
virtual SimpleJSON::Type::Object serialize() const override;
|
||||
|
||||
NeuronInterface& addNeuron() {
|
||||
neurons.push_back(new Neuron(neurons.size()));
|
||||
@@ -90,12 +97,17 @@ namespace Recurrent {
|
||||
*/
|
||||
NeuralNetwork::Recurrent::Network connectWith(const NeuralNetwork::Recurrent::Network &r) const;
|
||||
|
||||
static std::unique_ptr<Network> deserialize(const SimpleJSON::Type::Object&);
|
||||
|
||||
typedef SimpleJSON::Factory<Network> Factory;
|
||||
protected:
|
||||
size_t inputSize=0;
|
||||
size_t outputSize=0;
|
||||
|
||||
std::vector<NeuronInterface*> neurons;
|
||||
std::vector<float> outputs;
|
||||
|
||||
SIMPLEJSON_REGISTER(NeuralNetwork::Recurrent::Network::Factory,NeuralNetwork::Recurrent::Network, deserialize)
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user