pub struct TrainingLoop { /* private fields */ }Expand description
The main training orchestrator.
Coordinates data batching, forward/backward passes, optimizer steps, LR scheduling, early stopping, distributed gradient synchronisation, and callback dispatch.
Implementations§
Source§impl TrainingLoop
impl TrainingLoop
Sourcepub fn new(config: TrainingConfig) -> Self
pub fn new(config: TrainingConfig) -> Self
Create a new TrainingLoop with the given configuration.
Uses LocalGradientSync by default (no distributed sync).
Sourcepub fn add_callback(&mut self, cb: Box<dyn TrainingCallback>)
pub fn add_callback(&mut self, cb: Box<dyn TrainingCallback>)
Register a training callback.
Sourcepub fn with_gradient_sync(self, sync: Box<dyn GradientSync>) -> Self
pub fn with_gradient_sync(self, sync: Box<dyn GradientSync>) -> Self
Override the gradient synchronization strategy.
Sourcepub fn run(
&mut self,
data: &dyn DataProvider,
optimizer: &mut dyn Optimizer,
lr_scheduler: &mut dyn LrScheduler,
early_stopping: Option<&mut EarlyStopping>,
model_weights: &mut Array1<f32>,
model_bias: &mut f32,
) -> ModelResult<TrainingResult>
pub fn run( &mut self, data: &dyn DataProvider, optimizer: &mut dyn Optimizer, lr_scheduler: &mut dyn LrScheduler, early_stopping: Option<&mut EarlyStopping>, model_weights: &mut Array1<f32>, model_bias: &mut f32, ) -> ModelResult<TrainingResult>
Run training.
§Parameters
data: dataset providing batched samples.optimizer: mutable reference to anyOptimizerimplementation.lr_scheduler: mutable reference to anyLrSchedulerimplementation.early_stopping: optional early-stopping guard fromcrate::checkpoint.model_weights: mutable weight vector; updated in-place each epoch.model_bias: mutable bias scalar; updated in-place each epoch.
§Returns
A TrainingResult summarising the completed run.
Auto Trait Implementations§
impl Freeze for TrainingLoop
impl !RefUnwindSafe for TrainingLoop
impl Send for TrainingLoop
impl !Sync for TrainingLoop
impl Unpin for TrainingLoop
impl UnsafeUnpin for TrainingLoop
impl !UnwindSafe for TrainingLoop
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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