Skip to contents

Mini-batch stochastic gradient descent for OLS (R parity)

Usage

morie_mini_batch_gradient(
  x,
  y,
  lr = 0.01,
  n_epochs = 200,
  batch_size = 32L,
  seed = 0L
)

Arguments

x

Numeric matrix / vector predictors.

y

Numeric response.

lr

Learning rate.

n_epochs

Number of passes over the data.

batch_size

Mini-batch size.

seed

RNG seed for shuffling.

Value

Named list: estimate, reference_ols, n_epochs, batch_size, loss, n, method.

Examples

morie_mini_batch_gradient(x = rnorm(50), y = rnorm(50))
#> $estimate
#> [1]  0.11399434 -0.06680088
#> 
#> $reference_ols
#> [1]  0.11477864 -0.06321482
#> 
#> $n_epochs
#> [1] 200
#> 
#> $batch_size
#> [1] 32
#> 
#> $loss
#> [1] 0.7347753
#> 
#> $n
#> [1] 50
#> 
#> $method
#> [1] "Mini-batch SGD (linear regression)"
#>