/**
  * Calculates a hidden node's delta based on the layer behind it.
  *
  * @param PerceptronInterface $perceptron The perceptron in which we calculate.
  * @param Node $subject The subjected node which weight gets recalculated.
  * @param LayerInterface $behind The layer connected behind the subject.
  * @return float The delta for the subject.
  */
 public function calculateHiddenDelta(PerceptronInterface $perceptron, Node $subject, LayerInterface $behind)
 {
     // Calculate error by deltas from layer behind.
     $error = PerceptronUtil::dot($perceptron->getOutgoingWeights($subject), $behind->getDeltas());
     return $this->calculateDelta($subject, $error);
 }
Пример #2
0
 /**
  * @param LayerInterface $layerInFront
  * @param Node $node
  */
 private function updateNodesInFront(LayerInterface $layerInFront, Node $node)
 {
     $multi = $this->getLearningRate() * $node->delta;
     foreach ($layerInFront->getNodes() as $nodeInFront) {
         $deltaWeight = $multi * $nodeInFront->value;
         $this->decreaseWeight($nodeInFront, $node, $deltaWeight);
     }
 }