pub struct TrainingFitOptions<'fit, 'runtime> {
pub categorical_accuracy: bool,
pub validation: Option<&'fit mut dyn FnMut() -> Result<EvaluationReport>>,
pub checkpoint: Option<(&'fit mut CheckpointManager<'runtime>, &'fit dyn Module)>,
pub accumulation_steps: u64,
pub resume: Option<RunState>,
pub precision: Option<PrecisionPolicy>,
pub scaler: Option<&'fit mut GradScaler>,
}Expand description
Optional classification metrics, validation, and checkpointing for a fit.
Fields§
§categorical_accuracy: boolAccumulate categorical accuracy without per-batch host observation.
validation: Option<&'fit mut dyn FnMut() -> Result<EvaluationReport>>Evaluate the held-out split after each complete epoch.
checkpoint: Option<(&'fit mut CheckpointManager<'runtime>, &'fit dyn Module)>Save and restore the best validation loss with the native checkpoint manager.
accumulation_steps: u64Microbatches per optimizer update. One preserves the per-batch update contract exactly. Above one, the loop owns the accumulation window: each microbatch objective is scaled to a per-sample sum before backward, parameter gradients accumulate across the window, the exact window denominator corrects them before the update — so incomplete tail windows remain exact rather than mean-of-means — and lifecycle update counters, completion hooks, and schedules observe one step per applied update while sample accounting counts every microbatch. Managed fits derive the parameter set from the model; caller-driven batch sources must leave this at one.
resume: Option<RunState>Exact-resume position loaded beside an incremental checkpoint. The run
continues at resume.epoch — epochs remains the total epoch budget of
the run, so a resumed fit executes resume.epoch..epochs. A nonzero
loader cursor continues a partial first epoch; commits the managed fit
writes itself always land on epoch boundaries, but manual loops may
commit mid-epoch. Registered per-module RNG streams and checkpoint
best-selection criteria carried in resume are restored before the
resumed loop runs. When scaler is also provided, resume.scaler is
restored onto it before the resumed loop runs.
precision: Option<PrecisionPolicy>Optional runtime-scoped precision policy entered for the duration of this fit and restored automatically when the fit returns.
scaler: Option<&'fit mut GradScaler>Optional dynamic gradient scaler for mixed-precision managed fits.
Required whenever the effective precision policy requires scaling
(such as PrecisionPolicy::f16_storage).