summaryrefslogtreecommitdiff
path: root/src/brain/neuron.cpp
blob: 527e7da6ce18e4aa5fa22e26088b013733a9f1b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "brain/neuron.h"
#include <cmath>

Neuron::Neuron(int id)
    :NeuralNode('n', id)
{
}

double Neuron::sigmoid(double input) const
{
    double slope = 4.924273;
    return (1/(1+(std::exp(-(slope*input)))));
}

double Neuron::activation() const
{
    double activationSum = 0;
    for (auto const& link : _inputLinks)
    {
	activationSum += link->weightedActivation();
    }
    return sigmoid(activationSum);
}

void Neuron::addInput(std::unique_ptr<NeuralLink>&& link)
{
    _inputLinks.push_back(std::move(link));
}