pub struct CosineAnnealingLr { /* private fields */ }Expand description
Cosine annealing learning-rate scheduler.
Computes:
lr = min_lr + 0.5 * (base_lr - min_lr) * (1 + cos(pi * t_cur / t_max)),
where t_cur is clamped to t_max.
Implementations§
Source§impl CosineAnnealingLr
impl CosineAnnealingLr
Sourcepub fn new(t_max: usize, min_lr: f32) -> Result<Self, OptimError>
pub fn new(t_max: usize, min_lr: f32) -> Result<Self, OptimError>
Creates cosine scheduler with t_max > 0 and finite min_lr >= 0.
Sourcepub fn with_base_lr(self, base_lr: f32) -> Result<Self, OptimError>
pub fn with_base_lr(self, base_lr: f32) -> Result<Self, OptimError>
Pins explicit base LR used by cosine schedule.
pub fn t_max(&self) -> usize
pub fn min_lr(&self) -> f32
pub fn base_lr(&self) -> Option<f32>
pub fn epoch(&self) -> usize
pub fn reset(&mut self)
pub fn step<O: LearningRate>( &mut self, optimizer: &mut O, ) -> Result<f32, OptimError>
Trait Implementations§
Source§impl Clone for CosineAnnealingLr
impl Clone for CosineAnnealingLr
Source§fn clone(&self) -> CosineAnnealingLr
fn clone(&self) -> CosineAnnealingLr
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 CosineAnnealingLr
impl Debug for CosineAnnealingLr
Source§impl LrScheduler for CosineAnnealingLr
impl LrScheduler for CosineAnnealingLr
Source§impl PartialEq for CosineAnnealingLr
impl PartialEq for CosineAnnealingLr
impl StructuralPartialEq for CosineAnnealingLr
Auto Trait Implementations§
impl Freeze for CosineAnnealingLr
impl RefUnwindSafe for CosineAnnealingLr
impl Send for CosineAnnealingLr
impl Sync for CosineAnnealingLr
impl Unpin for CosineAnnealingLr
impl UnsafeUnpin for CosineAnnealingLr
impl UnwindSafe for CosineAnnealingLr
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
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 more