public function next() { if ($this->valid()) { if (Net::DIRECT == $this->_needToChangeDirection()) { Net::incrementIteration(); if (Net::shouldReloadValues()) { if (Net::isDebugEnabled()) { var_dump("<h1>Reloading</h1>"); } $this->reloadValues(); //reload values } } elseif (Net::REVERSE == $this->_needToChangeDirection()) { Net::setDirection(Net::REVERSE); //set reverse direction } $this->_level += Net::getLayoutCounter(); //go to next layout } }
/** * @throws \Exception * @return bool */ public function calculate() { //Calculating value $_sum = array_sum($this->getSignals()); $_sum += $this->getLayout()->getOffset(); $this->_value = $this->_binarSigmoid($_sum); if (Net::isTeacherMode()) { Net::setDirection(Net::REVERSE); $_value = ($this->_teacherValue - $this->_value) * $this->_diffBinarSigmoid($_sum); //new value will be mistake if (Net::isDebugEnabled()) { //Print value and teacher value/ var_dump("Summ: {$_value}. Teacher : " . $this->_teacherValue . ". Value: " . $this->_value); } $this->setValue($_value); } else { $this->getLayout()->compare($this); //add to lead neurons if this neuron has the max value } return true; }