From 6fd23da97fa9700f59c61a966b4bf7d25fa46b34 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 03:15:03 +0100 Subject: initial commit --- FullyRN.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 FullyRN.cpp (limited to 'FullyRN.cpp') diff --git a/FullyRN.cpp b/FullyRN.cpp new file mode 100644 index 0000000..ecc88d5 --- /dev/null +++ b/FullyRN.cpp @@ -0,0 +1,40 @@ +#include "FullyRN.hpp" + +FullyRN::FullyRN(unsigned inputCount, unsigned hiddenNodeCount, unsigned outputCount, NodeClass nodeClass, bool zeroed) +: DualMLP(0, 0, 0, NEURON, true) +{ + unsigned contextSize = inputCount + hiddenNodeCount + outputCount; + m_context.resize(contextSize, 0.f); + + m_firstHiddenLayer = NodeLayer(inputCount + contextSize, inputCount, nodeClass, zeroed); + m_secondHiddenLayer = NodeLayer(contextSize, hiddenNodeCount, nodeClass, zeroed); + m_outputLayer = NodeLayer(contextSize, outputCount, nodeClass, zeroed); + + m_inputCount = inputCount; + m_hiddenNodeCount = hiddenNodeCount; + m_outputCount = outputCount; + m_nodeClass = nodeClass; +} + +std::vector FullyRN::io(const std::vector &inputs) +{ + std::vector response; + + if (inputs.size() != m_inputCount) + { + return response; + } + + auto stateInput = inputs; + stateInput.insert(stateInput.end(), m_context.begin(), m_context.end()); + response = m_firstHiddenLayer.io(stateInput); + + auto hiddenOutput = m_secondHiddenLayer.io(m_context); + response.insert(response.end(), hiddenOutput.begin(), hiddenOutput.end()); + + auto outputOutput = m_outputLayer.io(m_context); + response.insert(response.end(), outputOutput.begin(), outputOutput.end()); + + m_context = response; + return outputOutput; +} -- cgit v1.2.1