pub struct LinearDecayLR { /* private fields */ }Available on crate feature
alloc only.Expand description
Linearly interpolates the learning rate from initial_lr to final_lr
over decay_steps, then holds final_lr forever.
The formula is:
lr = initial_lr - (initial_lr - final_lr) * min(step / decay_steps, 1.0)This gives a smooth ramp-down that reaches final_lr at exactly
step == decay_steps and clamps there for all subsequent steps.
§Example
ⓘ
use irithyll::ensemble::lr_schedule::{LRScheduler, LinearDecayLR};
let mut sched = LinearDecayLR::new(0.1, 0.01, 100);
// At step 0 we get the initial rate.
assert!(crate::math::abs((sched.learning_rate(0, 0.0) - 0.1)) < 1e-12);
// At step 50 we're halfway.
assert!(crate::math::abs((sched.learning_rate(50, 0.0) - 0.055)) < 1e-12);
// At step 100 we've reached the final rate.
assert!(crate::math::abs((sched.learning_rate(100, 0.0) - 0.01)) < 1e-12);
// Beyond decay_steps the rate stays clamped.
assert!(crate::math::abs((sched.learning_rate(200, 0.0) - 0.01)) < 1e-12);Implementations§
Trait Implementations§
Source§impl Clone for LinearDecayLR
impl Clone for LinearDecayLR
Source§fn clone(&self) -> LinearDecayLR
fn clone(&self) -> LinearDecayLR
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LinearDecayLR
impl Debug for LinearDecayLR
Source§impl LRScheduler for LinearDecayLR
impl LRScheduler for LinearDecayLR
Auto Trait Implementations§
impl Freeze for LinearDecayLR
impl RefUnwindSafe for LinearDecayLR
impl Send for LinearDecayLR
impl Sync for LinearDecayLR
impl Unpin for LinearDecayLR
impl UnsafeUnpin for LinearDecayLR
impl UnwindSafe for LinearDecayLR
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