Sigma   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 12
dl 0
loc 39
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getNeuron() 0 3 1
A getSigma() 0 3 1
A getSigmaForNeuron() 0 11 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Phpml\NeuralNetwork\Training\Backpropagation;
6
7
use Phpml\NeuralNetwork\Node\Neuron;
8
9
class Sigma
10
{
11
    /**
12
     * @var Neuron
13
     */
14
    private $neuron;
15
16
    /**
17
     * @var float
18
     */
19
    private $sigma;
20
21
    public function __construct(Neuron $neuron, float $sigma)
22
    {
23
        $this->neuron = $neuron;
24
        $this->sigma = $sigma;
25
    }
26
27
    public function getNeuron(): Neuron
28
    {
29
        return $this->neuron;
30
    }
31
32
    public function getSigma(): float
33
    {
34
        return $this->sigma;
35
    }
36
37
    public function getSigmaForNeuron(Neuron $neuron): float
38
    {
39
        $sigma = 0.0;
40
41
        foreach ($this->neuron->getSynapses() as $synapse) {
42
            if ($synapse->getNode() == $neuron) {
43
                $sigma += $synapse->getWeight() * $this->getSigma();
44
            }
45
        }
46
47
        return $sigma;
48
    }
49
}
50