blob: 7ea02c697eb8881875a26c831aa459876b4b8ab5 (
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
29
|
#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);
}
void Neuron::addInput(std::shared_ptr<NeuralLink> link)
{
_inputLinks.push_back(link);
}
|