Learn R Programming

ggmlR (version 0.6.1)

lr_scheduler_step: Step-decay learning rate scheduler

Description

Multiplies the optimizer learning rate by gamma every step_size calls to $step().

Usage

lr_scheduler_step(optimizer, step_size, gamma = 0.1)

Value

An lr_scheduler_step environment

Arguments

optimizer

An ag_optimizer_adam or ag_optimizer_sgd environment.

step_size

Decay every this many steps (epochs).

gamma

Multiplicative decay factor (default 0.1).

Examples

Run this code
# \donttest{
w   <- ag_param(matrix(runif(4), 2, 2))
opt <- optimizer_adam(list(w = w), lr = 0.1)
sch <- lr_scheduler_step(opt, step_size = 10L, gamma = 0.5)
for (epoch in 1:30) sch$step()
opt$lr  # 0.1 * 0.5^3 = 0.0125
# }

Run the code above in your browser using DataLab