pub struct PlateauLR { /* private fields */ }Available on crate feature
alloc only.Expand description
Reduce learning rate when the loss plateaus.
Monitors current_loss and reduces the rate by factor whenever the loss
has not improved for patience consecutive steps. “Improved” means the
new loss is strictly less than the best-seen loss.
The rate is floored at min_lr to prevent it from vanishing entirely.
§Example
ⓘ
use irithyll::ensemble::lr_schedule::{LRScheduler, PlateauLR};
let mut sched = PlateauLR::new(0.1, 0.5, 3, 0.001);
// Improving loss -- rate stays at 0.1.
assert!(crate::math::abs((sched.learning_rate(0, 1.0) - 0.1)) < 1e-12);
assert!(crate::math::abs((sched.learning_rate(1, 0.9) - 0.1)) < 1e-12);
// Stagnating loss for patience=3 steps.
assert!(crate::math::abs((sched.learning_rate(2, 0.95) - 0.1)) < 1e-12);
assert!(crate::math::abs((sched.learning_rate(3, 0.95) - 0.1)) < 1e-12);
assert!(crate::math::abs((sched.learning_rate(4, 0.95) - 0.1)) < 1e-12);
// Patience exhausted -- rate drops to 0.1 * 0.5 = 0.05.
assert!(crate::math::abs((sched.learning_rate(5, 0.95) - 0.05)) < 1e-12);Implementations§
Source§impl PlateauLR
impl PlateauLR
Sourcepub fn new(initial_lr: f64, factor: f64, patience: u64, min_lr: f64) -> Self
pub fn new(initial_lr: f64, factor: f64, patience: u64, min_lr: f64) -> Self
Create a plateau-aware scheduler.
§Arguments
initial_lr– Starting learning rate.factor– Multiplicative reduction factor (e.g., 0.5 halves the rate).patience– Number of non-improving steps to tolerate before reducing.min_lr– Floor below which the rate will not be reduced.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PlateauLR
impl RefUnwindSafe for PlateauLR
impl Send for PlateauLR
impl Sync for PlateauLR
impl Unpin for PlateauLR
impl UnsafeUnpin for PlateauLR
impl UnwindSafe for PlateauLR
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more