pub struct ReduceLrOnPlateau { /* private fields */ }Expand description
Reduce learning rate when a metric has stopped improving.
When the metric has not improved for patience consecutive calls to
ReduceLrOnPlateau::step_with_metric, the learning rate is multiplied
by factor (clamped to min_lr).
Implementations§
Source§impl ReduceLrOnPlateau
impl ReduceLrOnPlateau
Sourcepub fn new(
factor: f32,
patience: usize,
min_lr: f32,
) -> Result<Self, OptimError>
pub fn new( factor: f32, patience: usize, min_lr: f32, ) -> Result<Self, OptimError>
Creates a plateau scheduler.
factor in (0, 1]patience >= 1min_lr >= 0and finite
pub fn factor(&self) -> f32
pub fn patience(&self) -> usize
pub fn min_lr(&self) -> f32
pub fn best_metric(&self) -> f32
pub fn wait(&self) -> usize
pub fn epoch(&self) -> usize
pub fn reset(&mut self)
Sourcepub fn step_with_metric<O: LearningRate>(
&mut self,
metric: f32,
optimizer: &mut O,
) -> Result<f32, OptimError>
pub fn step_with_metric<O: LearningRate>( &mut self, metric: f32, optimizer: &mut O, ) -> Result<f32, OptimError>
Steps the scheduler with a metric value. If the metric has not improved
for patience consecutive steps, the LR is reduced by factor.
Lower metric is considered better.
Trait Implementations§
Source§impl Clone for ReduceLrOnPlateau
impl Clone for ReduceLrOnPlateau
Source§fn clone(&self) -> ReduceLrOnPlateau
fn clone(&self) -> ReduceLrOnPlateau
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 ReduceLrOnPlateau
impl Debug for ReduceLrOnPlateau
Source§impl LrScheduler for ReduceLrOnPlateau
impl LrScheduler for ReduceLrOnPlateau
Source§fn step<O: LearningRate>(
&mut self,
optimizer: &mut O,
) -> Result<f32, OptimError>
fn step<O: LearningRate>( &mut self, optimizer: &mut O, ) -> Result<f32, OptimError>
Standard step without a metric does nothing to the LR
(use step_with_metric instead).
Source§impl PartialEq for ReduceLrOnPlateau
impl PartialEq for ReduceLrOnPlateau
impl StructuralPartialEq for ReduceLrOnPlateau
Auto Trait Implementations§
impl Freeze for ReduceLrOnPlateau
impl RefUnwindSafe for ReduceLrOnPlateau
impl Send for ReduceLrOnPlateau
impl Sync for ReduceLrOnPlateau
impl Unpin for ReduceLrOnPlateau
impl UnsafeUnpin for ReduceLrOnPlateau
impl UnwindSafe for ReduceLrOnPlateau
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