id = self::$counter++; $this->param = $param; } /** * Return the unique identifier of the parameter. * * @return int */ public function id() : int { return $this->id; } /** * Return the wrapped parameter. * * @return mixed */ public function param() { return $this->param; } /** * Update the parameter. * * @param Tensor $gradient * @param Optimizer $optimizer */ public function update(Tensor $gradient, Optimizer $optimizer) : void { $step = $optimizer->step($this, $gradient); $this->param = $this->param->subtract($step); } /** * Perform a deep copy of the object upon cloning. */ public function __clone() { $this->param = clone $this->param; } }