/** * @param Neuron $from * @throws \Exception */ public function send(Neuron $from) { //Choose @var int $_directionType $_directionType = Net::getDirection() == Net::DIRECT ? self::HIGHER_NEURON : self::LOWER_NEURON; if (!isset($this->_neurons[$_directionType])) { throw new \Exception("Something wrong is with direction ({$_directionType}) or relation wasn`t init."); } /** @var Neuron $to */ $to = $this->_neurons[$_directionType]; //var_dump("Value: " . $from->getValue() . " Class: " . get_class($from)); $to->addSignal($this->_weight * $from->getValue()); // If we are on mistake step we need to correct weights if (Net::isMistakeFlow()) { $this->_weightCorrection($to, $from); } }
/** * @return bool * @throws \Exception */ public function send() { //Choose @var int $_directionType $_directionType = Net::getDirection() == Net::DIRECT ? Relation::SIGNAL : Relation::MISTAKE; if (!isset($this->_relations[$_directionType]) || !is_array($this->_relations[$_directionType])) { if (Net::isTeacherMode()) { throw new \Exception("Cannot find direction: {$_directionType}"); } else { return false; //Production Mode shouldn`t have reverse direction } } /** @var Relation $relation */ foreach ($this->_relations[$_directionType] as $relation) { $relation->send($this); //Sending from current neuron } $this->flushSignals(); return true; }