pub struct TrainingState {
pub epoch: usize,
pub step: usize,
pub global_step: usize,
pub best_metric: Option<f32>,
pub best_metric_name: Option<String>,
pub loss_history: Vec<f32>,
pub val_loss_history: Vec<f32>,
pub lr_history: Vec<f32>,
pub custom_metrics: HashMap<String, Vec<f32>>,
}Expand description
Training state for checkpointing.
Fields§
§epoch: usizeCurrent epoch.
step: usizeCurrent step within epoch.
global_step: usizeGlobal step count.
best_metric: Option<f32>Best metric value seen so far.
best_metric_name: Option<String>Name of the best metric.
loss_history: Vec<f32>Training loss history (last N values).
val_loss_history: Vec<f32>Validation loss history.
lr_history: Vec<f32>Learning rate history.
custom_metrics: HashMap<String, Vec<f32>>Custom metrics.
Implementations§
Source§impl TrainingState
impl TrainingState
Sourcepub fn record_loss(&mut self, loss: f32)
pub fn record_loss(&mut self, loss: f32)
Record a training loss value.
Sourcepub fn record_val_loss(&mut self, loss: f32)
pub fn record_val_loss(&mut self, loss: f32)
Record a validation loss value.
Sourcepub fn record_metric(&mut self, name: &str, value: f32)
pub fn record_metric(&mut self, name: &str, value: f32)
Record a custom metric.
Sourcepub fn update_best(
&mut self,
name: &str,
value: f32,
higher_is_better: bool,
) -> bool
pub fn update_best( &mut self, name: &str, value: f32, higher_is_better: bool, ) -> bool
Update best metric if improved.
Sourcepub fn next_epoch(&mut self)
pub fn next_epoch(&mut self)
Increment epoch.
Trait Implementations§
Source§impl Clone for TrainingState
impl Clone for TrainingState
Source§fn clone(&self) -> TrainingState
fn clone(&self) -> TrainingState
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 TrainingState
impl Debug for TrainingState
Source§impl Default for TrainingState
impl Default for TrainingState
Source§fn default() -> TrainingState
fn default() -> TrainingState
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for TrainingState
impl<'de> Deserialize<'de> for TrainingState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TrainingState
impl RefUnwindSafe for TrainingState
impl Send for TrainingState
impl Sync for TrainingState
impl Unpin for TrainingState
impl UnwindSafe for TrainingState
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