MCordingley\Regression\Algorithm\GradientDescent\Schedule\Adagrad::update PHP Method

update() public method

public update ( array $gradient )
$gradient array
    public function update(array $gradient)
    {
        if (!$this->sumSquaredGradient) {
            $this->sumSquaredGradient = array_fill(0, count($gradient), 0.0);
        }
        foreach ($gradient as $index => $slope) {
            $this->sumSquaredGradient[$index] += pow($slope, 2);
        }
    }

Usage Example

示例#1
0
 public function testStep()
 {
     $schedule = new Adagrad(0.01, 1.0E-6);
     $schedule->update([1.0]);
     static::assertEquals(0.009999990000010001, $schedule->step(0));
 }