ReduceLROnPlateau

scalation.modeling.autograd.ReduceLROnPlateau
final class ReduceLROnPlateau(optim: Optimizer, mode: String = ..., factor: Double = ..., patience: Int = ..., threshold: Double = ..., thresholdMode: String = ..., cooldown: Int = ..., minLR: Double = ..., eps: Double = ..., verbose: Boolean = ...) extends LRScheduler

PyTorch-style ReduceLROnPlateau scheduler. Monitors a metric each epoch and reduces the learning rate when progress plateaus. Supports both "min" (e.g., loss) and "max" (e.g., accuracy) modes, with relative or absolute thresholds for determining improvement. The LR is reduced when the number of non-improving epochs exceeds patience, after which a cooldown period prevents further reductions. Each reduction follows: newLR = max(oldLR * factor, minLR), skipped when the change is too small (≤ eps). Non-finite metric values are ignored. Call step(metric) after each optimizer update. getLastLR returns the most recent learning rate.

Value parameters

cooldown

epochs to wait after a reduction during which bad-epoch counter stays at 0

eps

minimal effective LR change required to apply a reduction

factor

multiplicative decay factor in (0,1), i.e., newLR = oldLR * factor

minLR

lower bound on the learning rate

mode

"min" or "max" (target direction for improvement)

optim

the optimizer whose learning rate will be scheduled

patience

number of non-improving epochs tolerated before reduction (strictly > patience)

threshold

significance threshold (relative or absolute depending on thresholdMode)

thresholdMode

"rel" for relative margin, "abs" for absolute margin

verbose

if true, prints LR reduction messages

Attributes

Graph
Supertypes
trait LRScheduler
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def getLastLR: Double

Return the most recently updated learning rate.

Return the most recently updated learning rate.

Attributes

Definition Classes
override def step(currentMetric: Double): Unit

Update the scheduler using the monitored metric (e.g., validation loss). Must be called after each optimizer update. Steps: 1. Ignore non-finite metric values. 2. Test for significant improvement versus best. 3. Update counters (bad-epochs or reset during cooldown). 4. Trigger LR reduction when plateau persists (numBadEpochs > patience).

Update the scheduler using the monitored metric (e.g., validation loss). Must be called after each optimizer update. Steps: 1. Ignore non-finite metric values. 2. Test for significant improvement versus best. 3. Update counters (bad-epochs or reset during cooldown). 4. Trigger LR reduction when plateau persists (numBadEpochs > patience).

Value parameters

currentMetric

the metric value for this epoch

Attributes

Definition Classes

Inherited methods

def step(): Unit

Advance the scheduler one step (iteration-based). Default implementation throws an exception; override if supported.

Advance the scheduler one step (iteration-based). Default implementation throws an exception; override if supported.

Attributes

Inherited from:
LRScheduler