1 | <?php |
||
12 | class Neuron implements Node |
||
13 | { |
||
14 | /** |
||
15 | * @var Synapse[] |
||
16 | */ |
||
17 | protected $synapses = []; |
||
18 | |||
19 | /** |
||
20 | * @var ActivationFunction |
||
21 | */ |
||
22 | protected $activationFunction; |
||
23 | |||
24 | /** |
||
25 | * @var float |
||
26 | */ |
||
27 | protected $z; |
||
28 | |||
29 | /** |
||
30 | * @var float |
||
31 | */ |
||
32 | protected $output; |
||
33 | |||
34 | public function __construct(?ActivationFunction $activationFunction = null) |
||
35 | { |
||
36 | $this->activationFunction = $activationFunction ?: new Sigmoid(); |
||
37 | $this->synapses = []; |
||
38 | $this->output = 0; |
||
|
|||
39 | } |
||
40 | |||
41 | public function addSynapse(Synapse $synapse): void |
||
45 | |||
46 | /** |
||
47 | * @return Synapse[] |
||
48 | */ |
||
49 | public function getSynapses() |
||
53 | |||
54 | public function getOutput(): float |
||
67 | |||
68 | public function getDerivative(): float |
||
72 | |||
73 | public function reset(): void |
||
78 | } |
||
79 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.