pub struct LossTracker {
pub window_size: usize,
/* private fields */
}Expand description
Rolling-window tracker for scalar loss values recorded during training.
Provides moving average, min/max, and a simple improvement check useful for early stopping decisions.
Fields§
§window_size: usizeImplementations§
Source§impl LossTracker
impl LossTracker
Sourcepub fn new(window_size: usize) -> Self
pub fn new(window_size: usize) -> Self
Create a new tracker with the given sliding window capacity.
Sourcepub fn push(&mut self, loss: f64)
pub fn push(&mut self, loss: f64)
Record a new loss value, evicting the oldest if the window is full.
Sourcepub fn moving_average(&self) -> Option<f64>
pub fn moving_average(&self) -> Option<f64>
Arithmetic mean over the current window; None if empty.
Sourcepub fn is_improving(&self, patience: usize) -> bool
pub fn is_improving(&self, patience: usize) -> bool
Returns true when the minimum loss seen in the most-recent patience
values is strictly less than the minimum over the full window excluding
those recent values. This captures “the model has improved recently”.
Returns false when there are not enough data points to compare.
Trait Implementations§
Source§impl Clone for LossTracker
impl Clone for LossTracker
Source§fn clone(&self) -> LossTracker
fn clone(&self) -> LossTracker
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 moreAuto Trait Implementations§
impl Freeze for LossTracker
impl RefUnwindSafe for LossTracker
impl Send for LossTracker
impl Sync for LossTracker
impl Unpin for LossTracker
impl UnsafeUnpin for LossTracker
impl UnwindSafe for LossTracker
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