rate = $rate; $this->losses = $losses; $this->decay = $decay; } /** * Take a step of gradient descent for a given parameter. * * @internal * * @param Parameter $param * @param Tensor $gradient * @return Tensor */ public function step(Parameter $param, Tensor $gradient) : Tensor { $floor = floor($this->t / $this->losses); $rate = $this->rate * (1.0 / (1.0 + $floor * $this->decay)); ++$this->t; return $gradient->multiply($rate); } /** * Return the string representation of the object. * * @internal * * @return string */ public function __toString() : string { return "Step Decay (rate: {$this->rate}, steps: {$this->losses}, decay: {$this->decay})"; } }