node = $node; $this->weight = $weight ?: $this->generateRandomWeight(); } /** * @return float */ protected function generateRandomWeight(): float { return 1 / rand(5, 25) * (rand(0, 1) ? -1 : 1); } /** * @return float */ public function getOutput(): float { return $this->weight * $this->node->getOutput(); } /** * @param float $delta */ public function changeWeight($delta) { $this->weight += $delta; } /** * @return float */ public function getWeight() { return $this->weight; } /** * @return Node */ public function getNode() { return $this->node; } }