Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   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  }