Struct SupervisedTraining
pub struct SupervisedTraining<M>where
M: LearnerModel,{ /* private fields */ }Expand description
Structure to configure and launch supervised learning trainings.
Implementations§
§impl<M> SupervisedTraining<M>where
M: LearnerModel,
impl<M> SupervisedTraining<M>where
M: LearnerModel,
pub fn new(
directory: impl AsRef<Path>,
dataloader_train: Arc<dyn DataLoader<<M as TrainStep>::Input>>,
dataloader_valid: Arc<dyn DataLoader<<M as InferenceStep>::Input>>,
) -> SupervisedTraining<M>
pub fn new( directory: impl AsRef<Path>, dataloader_train: Arc<dyn DataLoader<<M as TrainStep>::Input>>, dataloader_valid: Arc<dyn DataLoader<<M as InferenceStep>::Input>>, ) -> SupervisedTraining<M>
Creates a new runner for a supervised training.
§Arguments
directory- The directory to save the checkpoints.dataloader_train- The dataloader for the training split.dataloader_valid- The dataloader for the validation split.
§impl<M> SupervisedTraining<M>where
M: LearnerModel,
impl<M> SupervisedTraining<M>where
M: LearnerModel,
pub fn with_training_strategy(
self,
training_strategy: TrainingStrategy<M>,
) -> SupervisedTraining<M>
pub fn with_training_strategy( self, training_strategy: TrainingStrategy<M>, ) -> SupervisedTraining<M>
Replace the default training strategy (SingleDeviceTrainingStrategy) with the provided one.
§Arguments
training_strategy- The training strategy.
pub fn with_metric_logger<ML>(self, logger: ML) -> SupervisedTraining<M>where
ML: MetricLogger + 'static,
pub fn with_metric_logger<ML>(self, logger: ML) -> SupervisedTraining<M>where
ML: MetricLogger + 'static,
pub fn with_progress_logger<PL>(self, logger: PL) -> SupervisedTraining<M>where
PL: TrainingProgressLogger + 'static,
pub fn with_progress_logger<PL>(self, logger: PL) -> SupervisedTraining<M>where
PL: TrainingProgressLogger + 'static,
pub fn with_checkpointing_strategy<CS>(
self,
strategy: CS,
) -> SupervisedTraining<M>where
CS: CheckpointingStrategy + 'static,
pub fn with_checkpointing_strategy<CS>(
self,
strategy: CS,
) -> SupervisedTraining<M>where
CS: CheckpointingStrategy + 'static,
Update the checkpointing_strategy.
pub fn renderer(
self,
renderer: Box<dyn MetricsRenderer>,
) -> SupervisedTraining<M>
pub fn renderer( self, renderer: Box<dyn MetricsRenderer>, ) -> SupervisedTraining<M>
pub fn metrics<Me>(self, metrics: Me) -> SupervisedTraining<M>where
Me: MetricRegistration<M>,
pub fn metrics<Me>(self, metrics: Me) -> SupervisedTraining<M>where
Me: MetricRegistration<M>,
Register all metrics as numeric for the training and validation set.
pub fn metrics_text<Me>(self, metrics: Me) -> SupervisedTraining<M>where
Me: TextMetricRegistration<M>,
pub fn metrics_text<Me>(self, metrics: Me) -> SupervisedTraining<M>where
Me: TextMetricRegistration<M>,
Register all metrics as text for the training and validation set.
pub fn metric_train<Me>(self, metric: Me) -> SupervisedTraining<M>
pub fn metric_train<Me>(self, metric: Me) -> SupervisedTraining<M>
Register a training metric.
pub fn metric_valid<Me>(self, metric: Me) -> SupervisedTraining<M>
pub fn metric_valid<Me>(self, metric: Me) -> SupervisedTraining<M>
Register a validation metric.
pub fn grads_accumulation(self, accumulation: usize) -> SupervisedTraining<M>
pub fn grads_accumulation(self, accumulation: usize) -> SupervisedTraining<M>
Enable gradients accumulation.
§Notes
When you enable gradients accumulation, the gradients object used by the optimizer will be the sum of all gradients generated by each backward pass. It might be a good idea to reduce the learning to compensate.
The effect is similar to increasing the batch size and the learning rate by the accumulation
amount.
§Panics
Panics if accumulation is zero.
pub fn gradient_checkpointing(self) -> SupervisedTraining<M>
pub fn gradient_checkpointing(self) -> SupervisedTraining<M>
Enables autodiff checkpointing.
§Notes
Gradient checkpointing recomputes activations during backpropagation for operations marked as memory-bound, while compute-bound operations still cache their output. This reduces peak memory usage at the cost of additional computation for memory-bound ops.
pub fn metric_train_numeric<Me>(self, metric: Me) -> SupervisedTraining<M>
pub fn metric_train_numeric<Me>(self, metric: Me) -> SupervisedTraining<M>
pub fn metric_valid_numeric<Me>(self, metric: Me) -> SupervisedTraining<M>
pub fn metric_valid_numeric<Me>(self, metric: Me) -> SupervisedTraining<M>
pub fn num_epochs(self, num_epochs: usize) -> SupervisedTraining<M>
pub fn num_epochs(self, num_epochs: usize) -> SupervisedTraining<M>
The number of epochs the training should last.
pub fn checkpoint(self, checkpoint: usize) -> SupervisedTraining<M>
pub fn checkpoint(self, checkpoint: usize) -> SupervisedTraining<M>
The epoch from which the training must resume.
pub fn interrupter(&self) -> Interrupter
pub fn interrupter(&self) -> Interrupter
Provides a handle that can be used to interrupt training.
pub fn with_interrupter(self, interrupter: Interrupter) -> SupervisedTraining<M>
pub fn with_interrupter(self, interrupter: Interrupter) -> SupervisedTraining<M>
Override the handle for stopping training with an externally provided handle
pub fn early_stopping<Strategy>(
self,
strategy: Strategy,
) -> SupervisedTraining<M>
pub fn early_stopping<Strategy>( self, strategy: Strategy, ) -> SupervisedTraining<M>
Register an early stopping strategy to stop the training when the conditions are meet.
pub fn with_application_logger(
self,
logger: Option<Box<dyn ApplicationLoggerInstaller>>,
) -> SupervisedTraining<M>
pub fn with_application_logger( self, logger: Option<Box<dyn ApplicationLoggerInstaller>>, ) -> SupervisedTraining<M>
By default, Rust logs are captured and written into
experiment.log. If disabled, standard Rust log handling
will apply.
pub fn with_default_checkpointers(self) -> SupervisedTraining<M>
pub fn with_default_checkpointers(self) -> SupervisedTraining<M>
Register a checkpointer that will save the optimizer, the model and the learning rate scheduler to separate burnpack files.
pub fn with_custom_checkpointers<CM, CO, CL>(
self,
module_checkpointer: CM,
optimizer_checkpointer: CO,
lr_checkpointer: CL,
) -> SupervisedTraining<M>where
CM: Checkpointer<ModuleRecord> + 'static,
CO: Checkpointer<OptimizerRecord> + 'static,
CL: Checkpointer<LrSchedulerRecord> + 'static,
pub fn with_custom_checkpointers<CM, CO, CL>(
self,
module_checkpointer: CM,
optimizer_checkpointer: CO,
lr_checkpointer: CL,
) -> SupervisedTraining<M>where
CM: Checkpointer<ModuleRecord> + 'static,
CO: Checkpointer<OptimizerRecord> + 'static,
CL: Checkpointer<LrSchedulerRecord> + 'static,
Register your own checkpointers that will save the optimizer, the model and the learning rate scheduler to separate burnpack files.
pub fn summary(self) -> SupervisedTraining<M>
pub fn summary(self) -> SupervisedTraining<M>
Enable the training summary report.
The summary will be displayed after .fit(), when the renderer is dropped.
pub fn label(self, label: &str) -> SupervisedTraining<M>
pub fn label(self, label: &str) -> SupervisedTraining<M>
Set a label for this training, making it easier to differentiate multiple runs.
§impl<M> SupervisedTraining<M>where
M: LearnerModel,
impl<M> SupervisedTraining<M>where
M: LearnerModel,
pub fn launch(self, learner: Learner<M>) -> LearningResult<M>
pub fn launch(self, learner: Learner<M>) -> LearningResult<M>
Launch this training with the given Learner.
Auto Trait Implementations§
impl<M> !RefUnwindSafe for SupervisedTraining<M>
impl<M> !Send for SupervisedTraining<M>
impl<M> !Sync for SupervisedTraining<M>
impl<M> !UnwindSafe for SupervisedTraining<M>
impl<M> Freeze for SupervisedTraining<M>
impl<M> Unpin for SupervisedTraining<M>
impl<M> UnsafeUnpin for SupervisedTraining<M>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<K, Q> Comparable<Q> for K
impl<K, Q> Comparable<Q> for K
§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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