From e6ab4a8ed100d5d5b7611c74cf3ccd556f1f1d71 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 19:04:34 +0100 Subject: Initial commit --- include/HyperNeat/NeuralNet.hpp | 78 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 include/HyperNeat/NeuralNet.hpp (limited to 'include/HyperNeat/NeuralNet.hpp') diff --git a/include/HyperNeat/NeuralNet.hpp b/include/HyperNeat/NeuralNet.hpp new file mode 100644 index 0000000..7f4a81f --- /dev/null +++ b/include/HyperNeat/NeuralNet.hpp @@ -0,0 +1,78 @@ +#ifndef __HYPERNEAT_NEURALNET_HPP__ +#define __HYPERNEAT_NEURALNET_HPP__ + +#include +#include + +namespace hyperneat +{ + class Cppn; + class NeuralNetPrms; + + class NeuralNet + { + public: + class Neuron; + + NeuralNet() = default; + + void create(Cppn& cppn, const NeuralNetPrms& nnPrms); + void clear(); + + size_t getInputsCount() const; + size_t getOutputsCount() const; + size_t getNeuronsCount() const; + + const Vector& getInputs() const; + const Vector& getOutputs() const; + const Vector& getNeurons() const; + + double getAverageActivation() const; + + double& inputAt(size_t i); + double outputAt(size_t i) const; + + void cycle(); + + class Neuron + { + public: + enum class Type { + INPUT, HIDDEN, OUTPUT + }; + + Neuron() = default; + Neuron(const Point& position, Type type, double bias); + + void appendInput(); + void flushOutput(); + + class Synapse + { + public: + Synapse() = default; + Synapse(Neuron* inputNeuron, double weight); + + double* _input = nullptr; + Neuron* _neuron = nullptr; + double _weight = 0.0; + }; + + Vector _synapses; + Point _position; + Type _type = Type::HIDDEN; + double _bias = 0.0; + double _storedInput = 0.0; + double _output = 0.0; + }; + + private: + Vector _inputs; + Vector _outputs; + Vector _neurons; + + friend class Organism; + }; +} + +#endif -- cgit v1.2.1