pub struct ReduceLROnPlateauScheduler {
pub factor: f64,
pub patience: usize,
pub min_lr: f64,
pub threshold: f64,
pub cooldown: usize,
/* private fields */
}Expand description
Reduce learning rate on plateau (metric-based adaptive scheduler).
Reduces learning rate when a metric (e.g., validation loss) has stopped improving.
This scheduler requires explicit metric updates via step_with_metric().
Fields§
§factor: f64Decay factor.
patience: usizeNumber of epochs with no improvement after which LR will be reduced.
min_lr: f64Minimum LR.
threshold: f64Threshold for measuring improvement (relative).
cooldown: usizeNumber of epochs to wait before resuming normal operation after LR reduction.
Implementations§
Source§impl ReduceLROnPlateauScheduler
impl ReduceLROnPlateauScheduler
Sourcepub fn new(
initial_lr: f64,
mode: PlateauMode,
factor: f64,
patience: usize,
threshold: f64,
min_lr: f64,
cooldown: usize,
) -> Self
pub fn new( initial_lr: f64, mode: PlateauMode, factor: f64, patience: usize, threshold: f64, min_lr: f64, cooldown: usize, ) -> Self
Create a new ReduceLROnPlateau scheduler.
§Arguments
initial_lr- Initial learning ratemode- Whether to minimize or maximize the metricfactor- Factor by which to reduce LR (new_lr = lr * factor)patience- Number of epochs with no improvement to waitthreshold- Threshold for measuring improvement (relative)min_lr- Minimum LR (won’t reduce below this)cooldown- Cooldown epochs after LR reduction
Sourcepub fn step_with_metric(&mut self, optimizer: &mut dyn Optimizer, metric: f64)
pub fn step_with_metric(&mut self, optimizer: &mut dyn Optimizer, metric: f64)
Step with a metric value.
This should be called with the validation metric at the end of each epoch.
Trait Implementations§
Source§impl Clone for ReduceLROnPlateauScheduler
impl Clone for ReduceLROnPlateauScheduler
Source§fn clone(&self) -> ReduceLROnPlateauScheduler
fn clone(&self) -> ReduceLROnPlateauScheduler
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 ReduceLROnPlateauScheduler
impl Debug for ReduceLROnPlateauScheduler
Source§impl LrScheduler for ReduceLROnPlateauScheduler
impl LrScheduler for ReduceLROnPlateauScheduler
Auto Trait Implementations§
impl Freeze for ReduceLROnPlateauScheduler
impl RefUnwindSafe for ReduceLROnPlateauScheduler
impl Send for ReduceLROnPlateauScheduler
impl Sync for ReduceLROnPlateauScheduler
impl Unpin for ReduceLROnPlateauScheduler
impl UnwindSafe for ReduceLROnPlateauScheduler
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