summaryrefslogtreecommitdiff
path: root/src/brain/neuron.cpp
blob: 8c2e47ccb08993ebcee8912619c2d868f998b785 (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
#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);
}