Trainer¶
Training orchestrator with checkpointing, evaluation, and optimizer lifecycle management.
- class taktiny.trainer.Trainer(model, training_config, dataset_config, *, loss_fn, loss_has_aux=False, callbacks=None, compute_metrics=None)[source]¶
Bases:
TrainerEvaluateMixin,TrainerCheckpointMixinTrain a model on caller-provided batch iterables with an explicit loss.
DatasetConfig owns only batch placement/prefetch settings: dataset loading, preprocessing, batching, and sampling are external responsibilities. Training checkpoints use native Orbax, including dynamic model leaves, optional optimizer/EMA state, RNGs, and iterator progress. Static model configuration must be supplied again when constructing a resumed Trainer.
- Parameters:
model (Any)
training_config (TrainingConfig)
dataset_config (DatasetConfig)
loss_fn (LossFn)
loss_has_aux (bool)
callbacks (Iterable[Any] | Any | None)
compute_metrics (Callable[..., Mapping[str, Any]] | None)
- train(resume_from_checkpoint=None)[source]¶
Train on caller-provided batches; resume a native Orbax checkpoint.
Pass a checkpoint directory or ‘latest’. Supply the same model structure, optimizer, and data pipeline for exact resume. Async writes are drained on both success and failure before returning to the caller.
- Return type:
- Parameters:
resume_from_checkpoint (PathLike | None)