pub struct EarlyStopping { /* private fields */ }Expand description
Early stopping to halt training when a metric stops improving.
Implementations§
Source§impl EarlyStopping
impl EarlyStopping
Sourcepub fn new(patience: usize, min_delta: f32, mode: MonitorMode) -> Self
pub fn new(patience: usize, min_delta: f32, mode: MonitorMode) -> Self
Create a new early stopping monitor.
patience: number of epochs without improvement before stopping.min_delta: minimum change to qualify as an improvement.mode: whether lower or higher metric values are better.
Sourcepub fn check(&mut self, value: f32) -> bool
pub fn check(&mut self, value: f32) -> bool
Check if training should stop. Call once per epoch with the monitored metric.
Returns true when the patience has been exhausted (training should stop).
Sourcepub fn best_value(&self) -> f32
pub fn best_value(&self) -> f32
Best value seen so far.
Source§impl EarlyStopping
impl EarlyStopping
Sourcepub fn with_monitor(self, key: impl Into<String>) -> Self
pub fn with_monitor(self, key: impl Into<String>) -> Self
Set the metric key to monitor (default: "loss").
Trait Implementations§
Source§impl Clone for EarlyStopping
impl Clone for EarlyStopping
Source§fn clone(&self) -> EarlyStopping
fn clone(&self) -> EarlyStopping
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 EarlyStopping
impl Debug for EarlyStopping
Source§impl TrainingCallback for EarlyStopping
impl TrainingCallback for EarlyStopping
Auto Trait Implementations§
impl Freeze for EarlyStopping
impl RefUnwindSafe for EarlyStopping
impl Send for EarlyStopping
impl Sync for EarlyStopping
impl Unpin for EarlyStopping
impl UnsafeUnpin for EarlyStopping
impl UnwindSafe for EarlyStopping
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