sgd: Stochastic Gradient Descent

Description Usage Arguments Value Examples

View source: R/gradesc.R

Description

Stochastic Gradient Descent

Usage

1
sgd(alpha, X, y, grad, N, precision = 1e-04)

Arguments

alpha

learning rate constant

X

matrix of predictors including 1 for beta 0

y

vector of dependent variable

grad

gradient function

N

maximum number of iterations

precision

constant used for approximation condition

Value

list object with theta, convergence status, and number of iterations

Examples

1
2
3
4
5
6
7
x <- runif(1000, -5, 5)
y <- x + rnorm(1000) + 3
X <- cbind(1, matrix(x))
h <- sgd(0.1, X, y, least_squares_gradient, 1000)
h$theta
h$converged == TRUE
h$iterations

tbonza/supml documentation built on May 17, 2019, 3:14 a.m.