pub struct PolynomialDecayLr { /* private fields */ }Expand description
Polynomial decay learning-rate scheduler.
Decays the learning rate from its initial value to end_lr over total_steps
using a polynomial of the given power:
lr = (base_lr - end_lr) * (1 - epoch/total_steps)^power + end_lr.
Implementations§
Source§impl PolynomialDecayLr
impl PolynomialDecayLr
Sourcepub fn new(
total_steps: usize,
power: f32,
end_lr: f32,
) -> Result<Self, OptimError>
pub fn new( total_steps: usize, power: f32, end_lr: f32, ) -> Result<Self, OptimError>
Creates polynomial decay scheduler.
total_steps > 0power > 0and finiteend_lr >= 0and finite
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 total_steps(&self) -> usize
pub fn power(&self) -> f32
pub fn end_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 PolynomialDecayLr
impl Clone for PolynomialDecayLr
Source§fn clone(&self) -> PolynomialDecayLr
fn clone(&self) -> PolynomialDecayLr
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 PolynomialDecayLr
impl Debug for PolynomialDecayLr
Source§impl LrScheduler for PolynomialDecayLr
impl LrScheduler for PolynomialDecayLr
Source§impl PartialEq for PolynomialDecayLr
impl PartialEq for PolynomialDecayLr
impl StructuralPartialEq for PolynomialDecayLr
Auto Trait Implementations§
impl Freeze for PolynomialDecayLr
impl RefUnwindSafe for PolynomialDecayLr
impl Send for PolynomialDecayLr
impl Sync for PolynomialDecayLr
impl Unpin for PolynomialDecayLr
impl UnsafeUnpin for PolynomialDecayLr
impl UnwindSafe for PolynomialDecayLr
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