diff options
author | Justin Worthe <justin.worthe@gmail.com> | 2015-08-01 14:35:58 +0200 |
---|---|---|
committer | Justin Worthe <justin.worthe@gmail.com> | 2015-08-01 14:35:58 +0200 |
commit | 7e8dce7224214cbb82e9191917de9f234fe38cb7 (patch) | |
tree | 2ac58697c2004ef72b3cb52eb8cb53000ebdf86d /src/brain/neuron.cpp | |
parent | be9e20b29ce0ed81091ab3589f4910232b457cec (diff) |
Implemented structure of network
Diffstat (limited to 'src/brain/neuron.cpp')
-rw-r--r-- | src/brain/neuron.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/brain/neuron.cpp b/src/brain/neuron.cpp new file mode 100644 index 0000000..8c2e47c --- /dev/null +++ b/src/brain/neuron.cpp @@ -0,0 +1,24 @@ +#include "brain/neuron.h" +#include <cmath> + +Neuron::Neuron(int id) + :NeuralNode('n', id) +{ +} + +double Neuron::sigmoid(double input) const +{ + double slope = 4.924273; + double constant = 2.4621365; + return (1/(1+(std::exp(-(slope*input))))); +} + +double Neuron::activation() const +{ + double activationSum = 0; + for (auto link : _inputLinks) + { + activationSum += link->weightedActivation(); + } + return sigmoid(activationSum); +} |