pub struct CosineAnnealingWarmRestarts { /* private fields */ }Expand description
Cosine annealing with warm restarts learning-rate scheduler.
Within each period, LR follows cosine decay from base_lr to eta_min.
After t_0 epochs, the schedule restarts and the next period length is
t_0 * t_mult.
Formula within each period:
lr = eta_min + 0.5 * (base_lr - eta_min) * (1 + cos(pi * t_cur / t_i))
Implementations§
Source§impl CosineAnnealingWarmRestarts
impl CosineAnnealingWarmRestarts
Sourcepub fn new(t_0: usize, t_mult: usize, eta_min: f32) -> Result<Self, OptimError>
pub fn new(t_0: usize, t_mult: usize, eta_min: f32) -> Result<Self, OptimError>
Creates a cosine warm restarts scheduler.
t_0 > 0: initial period lengtht_mult >= 1: period multiplier after each restarteta_min >= 0: minimum learning rate
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 the schedule.
pub fn t_0(&self) -> usize
pub fn t_mult(&self) -> usize
pub fn eta_min(&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 CosineAnnealingWarmRestarts
impl Clone for CosineAnnealingWarmRestarts
Source§fn clone(&self) -> CosineAnnealingWarmRestarts
fn clone(&self) -> CosineAnnealingWarmRestarts
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 CosineAnnealingWarmRestarts
impl Debug for CosineAnnealingWarmRestarts
impl StructuralPartialEq for CosineAnnealingWarmRestarts
Auto Trait Implementations§
impl Freeze for CosineAnnealingWarmRestarts
impl RefUnwindSafe for CosineAnnealingWarmRestarts
impl Send for CosineAnnealingWarmRestarts
impl Sync for CosineAnnealingWarmRestarts
impl Unpin for CosineAnnealingWarmRestarts
impl UnsafeUnpin for CosineAnnealingWarmRestarts
impl UnwindSafe for CosineAnnealingWarmRestarts
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