Skip to main content

TrainingCallback

Trait TrainingCallback 

Source
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§

Source

fn on_epoch_start(&mut self, _epoch: usize)

Called at the start of each epoch.

Source

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.

Source

fn on_batch_end(&mut self, _epoch: usize, _batch: usize, _loss: f32)

Called after each mini-batch update.

Source

fn on_training_end(&mut self, _result: &TrainingResult)

Called once training finishes (either all epochs or early stopping).

Implementors§