aboutsummaryrefslogtreecommitdiff
path: root/SimpleRN.cpp
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-02-29 03:15:03 +0100
committerPaul Oliver <contact@pauloliver.dev>2024-02-29 03:15:30 +0100
commit6fd23da97fa9700f59c61a966b4bf7d25fa46b34 (patch)
treed5fe3a8305a5f57e5b4cedc8300e951c74696cc5 /SimpleRN.cpp
initial commitHEADmaster
Diffstat (limited to 'SimpleRN.cpp')
-rw-r--r--SimpleRN.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/SimpleRN.cpp b/SimpleRN.cpp
new file mode 100644
index 0000000..0e10c22
--- /dev/null
+++ b/SimpleRN.cpp
@@ -0,0 +1,35 @@
+#include "SimpleRN.hpp"
+
+SimpleRN::SimpleRN(unsigned inputCount, unsigned hiddenNodeCount, unsigned outputCount, NodeClass nodeClass, bool zeroed)
+: SingleMLP(0, 0, 0, NEURON, true)
+{
+ m_context.resize(hiddenNodeCount, 0.f);
+
+ m_hiddenLayer = NodeLayer(inputCount + hiddenNodeCount, hiddenNodeCount, nodeClass, zeroed);
+ m_outputLayer = NodeLayer(hiddenNodeCount, outputCount, nodeClass, zeroed);
+
+ m_inputCount = inputCount;
+ m_hiddenNodeCount = hiddenNodeCount;
+ m_outputCount = outputCount;
+ m_nodeClass = nodeClass;
+}
+
+std::vector<float> SimpleRN::io(const std::vector<float> &inputs)
+{
+ std::vector<float> response;
+
+ if (inputs.size() != m_inputCount)
+ {
+ return response;
+ }
+
+ response.insert(response.end(), inputs.begin(), inputs.end());
+ response.insert(response.end(), m_context.begin(), m_context.end());
+
+ response = m_hiddenLayer.io(response);
+
+ m_context = response;
+ response = m_outputLayer.io(response);
+
+ return response;
+}