blob: f4fa12f5c91110ca14d3c4f6892ac27f2bf19d55 (
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
|
#include "brain/neuron.h"
#include <cmath>
double Neuron::sigmoid(double input) const
{
double slope = 4.924273;
return (1/(1+(std::exp(-(slope*input)))));
}
void Neuron::calculateActivation()
{
double newActivation = 0;
for (auto const& link : _inputLinks)
{
newActivation += link->weightedActivation();
}
newActivation = sigmoid(newActivation);
_activationChanged = newActivation != _activation;
_activation = newActivation;
}
void Neuron::addInput(std::unique_ptr<NeuralLink>&& link)
{
_inputLinks.push_back(std::move(link));
}
|