pub struct ExponentialDecay<A: Float + Debug> { /* private fields */ }Expand description
Exponential decay learning rate scheduler
Applies exponential decay to the learning rate over time: lr = initial_lr * decay_rate^(step / decay_steps)
§Examples
use optirs_core::schedulers::{ExponentialDecay, LearningRateScheduler};
// Create a scheduler with initial learning rate 0.1, decay rate 0.95
// and decay steps 1000
let mut scheduler = ExponentialDecay::new(0.1f64, 0.95, 1000);
// Initial learning rate
let initial_lr = scheduler.get_learning_rate();
// Run for a few steps (reduced for test)
for _ in 0..3 {
// Update learning rate
let lr = scheduler.step();
// Verify learning rate is decaying
assert!(lr < initial_lr);
}
// Verify scheduler is working
let final_lr = scheduler.get_learning_rate();
assert!(final_lr < 0.1);Implementations§
Source§impl<A: Float + Debug + Send + Sync> ExponentialDecay<A>
impl<A: Float + Debug + Send + Sync> ExponentialDecay<A>
Sourcepub fn new(initial_lr: A, decay_rate: A, decay_steps: usize) -> Self
pub fn new(initial_lr: A, decay_rate: A, decay_steps: usize) -> Self
Create a new exponential decay scheduler
§Arguments
initial_lr- Initial learning ratedecay_rate- Rate at which learning rate decays (e.g., 0.95)decay_steps- Number of steps after which learning rate is decayed by decay_rate
Trait Implementations§
Source§impl<A: Clone + Float + Debug> Clone for ExponentialDecay<A>
impl<A: Clone + Float + Debug> Clone for ExponentialDecay<A>
Source§fn clone(&self) -> ExponentialDecay<A>
fn clone(&self) -> ExponentialDecay<A>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<A: Float + Debug + ScalarOperand + Send + Sync> LearningRateScheduler<A> for ExponentialDecay<A>
impl<A: Float + Debug + ScalarOperand + Send + Sync> LearningRateScheduler<A> for ExponentialDecay<A>
Source§fn get_learning_rate(&self) -> A
fn get_learning_rate(&self) -> A
Get the learning rate at the current step
Source§fn step_with_metric(&mut self, metric: A) -> A
fn step_with_metric(&mut self, metric: A) -> A
Update the scheduler state using an observed metric and return the new learning rate Read more
Auto Trait Implementations§
impl<A> Freeze for ExponentialDecay<A>where
A: Freeze,
impl<A> RefUnwindSafe for ExponentialDecay<A>where
A: RefUnwindSafe,
impl<A> Send for ExponentialDecay<A>where
A: Send,
impl<A> Sync for ExponentialDecay<A>where
A: Sync,
impl<A> Unpin for ExponentialDecay<A>where
A: Unpin,
impl<A> UnsafeUnpin for ExponentialDecay<A>where
A: UnsafeUnpin,
impl<A> UnwindSafe for ExponentialDecay<A>where
A: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.