
Single-sample SGD step (Geron Ch 4, morie.fn hmsgdu)
Source:R/geron_ml2_native.R
morie_geron_sgd_update.Rdtheta <- theta - eta * 2 x_i (x_i^T theta - y_i). With index NULL
the row is picked from ONE LCG draw, i = floor(u * n) capped at
n - 1, and is reported 0-based in index.
Value
List with theta, theta_next, gradient,
batch_gradient, residual, index (0-based), eta,
estimate, n.
Examples
morie_geron_sgd_update(X = c(1, 2, 3, 4, 5, 6, 7, 8), y = c(1, 2, 3, 4, 5, 6, 7, 8), theta = 0.5)
#> $theta
#> [1] 0.9
#>
#> $theta_next
#> [1] 0.9
#>
#> $gradient
#> [1] -4
#>
#> $batch_gradient
#> [1] -25.5
#>
#> $residual
#> [1] -1
#>
#> $index
#> [1] 1
#>
#> $eta
#> [1] 0.1
#>
#> $estimate
#> [1] 0.4
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "Single-sample least-squares SGD update theta <- theta - eta*2x(x^T theta - y)"
#>