pub struct LambdaLr { /* private fields */ }Expand description
Lambda learning-rate scheduler.
Computes lr = base_lr * lr_lambda(step_count) at each step, where
lr_lambda is a user-provided closure mapping epoch to a multiplicative
factor.
Implementations§
Source§impl LambdaLr
impl LambdaLr
Sourcepub fn new(base_lr: f32, lr_lambda: Box<dyn Fn(usize) -> f32>) -> Self
pub fn new(base_lr: f32, lr_lambda: Box<dyn Fn(usize) -> f32>) -> Self
Creates a lambda scheduler with the given base learning rate and lambda
function. The lambda receives the current epoch (after increment) and
returns a multiplicative factor applied to base_lr.
Sourcepub fn current_lr(&self) -> f32
pub fn current_lr(&self) -> f32
Returns the current learning rate.
Sourcepub fn step_count(&self) -> usize
pub fn step_count(&self) -> usize
Returns the current step count.
Sourcepub fn step<O: LearningRate>(
&mut self,
optimizer: &mut O,
) -> Result<f32, OptimError>
pub fn step<O: LearningRate>( &mut self, optimizer: &mut O, ) -> Result<f32, OptimError>
Advances scheduler by one epoch and returns resulting optimizer LR.
Trait Implementations§
Source§impl LrScheduler for LambdaLr
impl LrScheduler for LambdaLr
Auto Trait Implementations§
impl Freeze for LambdaLr
impl !RefUnwindSafe for LambdaLr
impl !Send for LambdaLr
impl !Sync for LambdaLr
impl Unpin for LambdaLr
impl UnsafeUnpin for LambdaLr
impl !UnwindSafe for LambdaLr
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> 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