Example #1
0
 /**
  * @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;
 }
Example #2
0
 /**
  * Check what mode we have -> iterate only in one side when we are using production mode, and use back propagation if we have also mistake flow
  * @return bool
  */
 public function valid()
 {
     if (!Net::validateIteration()) {
         return false;
     }
     if (!Net::isTeacherMode()) {
         return $this->_level != $this->count();
     } else {
         //back propaganation
         return !($this->_level == $this->count() && !Net::isMistakeFlow() && ($this->_level == 0 && Net::isMistakeFlow()));
     }
 }