/** * @param array $coefficients * @param array $gradient * @return array */ private function updateCoefficients(array $coefficients, array $gradient) : array { foreach ($gradient as $i => $slope) { $coefficients[$i] -= $this->schedule->step($i) * $slope; } return $coefficients; }
/** * @param array $gradient * @param array $coefficients * @return bool */ public function converged(array $gradient, array $coefficients) : bool { $steppedGradient = []; foreach ($gradient as $i => $slope) { $steppedGradient[] = $this->schedule->step($i) * $slope; } return $this->criteria->converged($steppedGradient, $coefficients); }