Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are 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  }