Skip to main content

Callback

Trait Callback 

Source
pub trait Callback {
    // Provided methods
    fn on_train_begin(&mut self, _state: &TrainingState) -> TrainResult<()> { ... }
    fn on_train_end(&mut self, _state: &TrainingState) -> TrainResult<()> { ... }
    fn on_epoch_begin(
        &mut self,
        _epoch: usize,
        _state: &TrainingState,
    ) -> TrainResult<()> { ... }
    fn on_epoch_end(
        &mut self,
        _epoch: usize,
        _state: &TrainingState,
    ) -> TrainResult<()> { ... }
    fn on_batch_begin(
        &mut self,
        _batch: usize,
        _state: &TrainingState,
    ) -> TrainResult<()> { ... }
    fn on_batch_end(
        &mut self,
        _batch: usize,
        _state: &TrainingState,
    ) -> TrainResult<()> { ... }
    fn on_validation_end(&mut self, _state: &TrainingState) -> TrainResult<()> { ... }
    fn should_stop(&self) -> bool { ... }
}
Expand description

Trait for training callbacks.

Provided Methods§

Source

fn on_train_begin(&mut self, _state: &TrainingState) -> TrainResult<()>

Called at the beginning of training.

Source

fn on_train_end(&mut self, _state: &TrainingState) -> TrainResult<()>

Called at the end of training.

Source

fn on_epoch_begin( &mut self, _epoch: usize, _state: &TrainingState, ) -> TrainResult<()>

Called at the beginning of an epoch.

Source

fn on_epoch_end( &mut self, _epoch: usize, _state: &TrainingState, ) -> TrainResult<()>

Called at the end of an epoch.

Source

fn on_batch_begin( &mut self, _batch: usize, _state: &TrainingState, ) -> TrainResult<()>

Called at the beginning of a batch.

Source

fn on_batch_end( &mut self, _batch: usize, _state: &TrainingState, ) -> TrainResult<()>

Called at the end of a batch.

Source

fn on_validation_end(&mut self, _state: &TrainingState) -> TrainResult<()>

Called after validation.

Source

fn should_stop(&self) -> bool

Check if training should stop early.

Implementors§