Skip to content
class

MultiStepLR

extendsLRScheduler
MultiStepLR

Milestone decay — multiply lr by γ\gamma at each passed milestone.

Math

ηt=η0⋅γ ∣{m∈M:m≤t}∣ \eta_t = \eta_0 \cdot \gamma^{\,|\{m \in M : m \le t\}|}

where MM is the sorted milestone set.

Attributes

milestones_vector of int
Epochs at which to apply the decay, sorted ascending at construction.
gamma_float
Multiplicative decay factor applied once per passed milestone.

Notes

Duplicate milestones decay the lr twice at the same epoch — this matches the reference framework's behaviour and is rarely useful in practice.

Constructors

1
ctor

MultiStepLR

void MultiStepLR(Optimizer & opt, int milestones, double gamma)

Build a milestone decay schedule.

Parameters

Target optimiser.
milestonesvector of int
Epochs at which to decay. Sorted ascending internally.
gammafloat, default 0.1
Multiplicative decay factor per milestone.

Methods

1
fnconst

compute_lr_at

→float
double compute_lr_at(int epoch)

Evaluate the milestone decay rule at epoch.

Parameters

epochint
Current epoch.

Returns

float

base_lr_ * gamma_ ** (number of passed milestones).