pub trait TrainingCallback: Send {
// Provided methods
fn on_epoch_start(&mut self, _epoch: usize) { ... }
fn on_epoch_end(
&mut self,
_epoch: usize,
_train_loss: f32,
_val_loss: Option<f32>,
) { ... }
fn on_batch_end(&mut self, _epoch: usize, _batch: usize, _loss: f32) { ... }
fn on_training_end(&mut self, _result: &TrainingResult) { ... }
}Expand description
Trait for objects that observe training events.
All methods have default no-op implementations so implementors only need to override the events they care about.
Provided Methods§
Sourcefn on_epoch_start(&mut self, _epoch: usize)
fn on_epoch_start(&mut self, _epoch: usize)
Called at the start of each epoch.
Sourcefn on_epoch_end(
&mut self,
_epoch: usize,
_train_loss: f32,
_val_loss: Option<f32>,
)
fn on_epoch_end( &mut self, _epoch: usize, _train_loss: f32, _val_loss: Option<f32>, )
Called at the end of each epoch with the epoch-level losses.
Sourcefn on_batch_end(&mut self, _epoch: usize, _batch: usize, _loss: f32)
fn on_batch_end(&mut self, _epoch: usize, _batch: usize, _loss: f32)
Called after each mini-batch update.
Sourcefn on_training_end(&mut self, _result: &TrainingResult)
fn on_training_end(&mut self, _result: &TrainingResult)
Called once training finishes (either all epochs or early stopping).