serializatioin / deserialization and tests
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Neuron.h"
|
||||
|
||||
#include <SimpleJSON/SerializableObject.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
#include "../Neuron.h"
|
||||
#include "../Stringifiable.h"
|
||||
|
||||
namespace NeuralNetwork {
|
||||
namespace FeedForward {
|
||||
|
||||
@@ -13,9 +14,10 @@ namespace FeedForward {
|
||||
* @author Tomas Cernik (Tom.Cernik@gmail.com)
|
||||
* @brief Class for Layer of FeedForward network
|
||||
*/
|
||||
class Layer : public Stringifiable {
|
||||
class Layer : public SimpleJSON::SerializableObject {
|
||||
|
||||
public:
|
||||
|
||||
Layer(std::size_t size, const ActivationFunction::ActivationFunction &activationFunction):neurons() {
|
||||
neurons.push_back(new BiasNeuron);
|
||||
for(std::size_t i=0;i<size;i++) {
|
||||
@@ -70,11 +72,18 @@ namespace FeedForward {
|
||||
}
|
||||
}
|
||||
|
||||
using Stringifiable::stringify;
|
||||
virtual void stringify(std::ostream& out) const override;
|
||||
virtual SimpleJSON::Type::Object serialize() const override;
|
||||
|
||||
static std::unique_ptr<Layer> deserialize(const SimpleJSON::Type::Object&);
|
||||
|
||||
typedef SimpleJSON::Factory<Layer> Factory;
|
||||
protected:
|
||||
std::vector<NeuronInterface*> neurons;
|
||||
private:
|
||||
Layer():neurons() {
|
||||
}
|
||||
|
||||
SIMPLEJSON_REGISTER(NeuralNetwork::FeedForward::Layer::Factory, NeuralNetwork::FeedForward::Layer,NeuralNetwork::FeedForward::Layer)
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user