Skip to content
class

CyclicLR

extendsLRScheduler
CyclicLR

Triangular cyclic learning-rate schedule (Smith, 2015).

Oscillates between base_lr and max_lr over cycles of length total_size_ = step_size_up + step_size_down. Each cycle linearly climbs to max_lr over step_size_up epochs then descends to base_lr over step_size_down epochs. Three amplitude profiles are supported via Mode.

Math

Let c=t/Tc = t / T be the cycle index, ϕ\phi the within-cycle phase, and AcA_c the cycle amplitude. Then

ηt=ηmin⁡+Ac⋅tri(ϕ) \eta_t = \eta_{\min} + A_c \cdot \mathrm{tri}(\phi)

where Triangular uses Ac=(ηmax⁡−ηmin⁡)A_c = (\eta_{\max} - \eta_{\min}) for every cycle, Triangular2 halves it as Ac=(ηmax⁡−ηmin⁡)/2cA_c = (\eta_{\max} - \eta_{\min})/2^c, and ExpRange decays it as (ηmax⁡−ηmin⁡) γt(\eta_{\max} - \eta_{\min})\,\gamma^t.

References

Smith, "Cyclical Learning Rates for Training Neural Networks" (WACV 2017, arXiv:1506.01186).

Parameters

Target optimiser.
base_lrfloat
Lower envelope of the triangle (distinct from base_lr_ in LRScheduler, which captures the optimiser's initial lr).
max_lrfloat
Upper envelope.
step_size_upint
Epochs for the ramp from base_lr to max_lr.
step_size_downint, default 0
Epochs for the descent. Zero ⇒ symmetric triangle of width 2 * step_size_up.
modeMode, default Mode::Triangular
Amplitude profile.
gammafloat, default 1.0
Per-step decay used only by ExpRange.

Attributes

base_lr_cyc_float
Lower envelope.
max_lr_float
Upper envelope.
step_size_up_int
Ramp length.
total_size_int
Cycle length.
mode_Mode
gamma_float

Constructors

1
ctor

CyclicLR

void CyclicLR(Optimizer & opt, double base_lr, double max_lr, int step_size_up, int step_size_down, Mode mode, double gamma)

Build a cyclic schedule.

Parameters

Target optimiser.
base_lrfloat
Lower envelope.
max_lrfloat
Upper envelope.
step_size_upint
Epochs for the upward ramp.
step_size_downint, default 0
Epochs for the downward ramp. Zero ⇒ symmetric.
modeMode, default Mode::Triangular
Amplitude profile.
gammafloat, default 1.0
Decay used only by Mode::ExpRange.

Methods

1
fnconst

compute_lr_at

→float
double compute_lr_at(int epoch)

Evaluate the cyclic schedule at epoch.

Parameters

epochint
Current epoch.

Returns

float

Scheduled learning rate.