Trainer
The trainer is the concrete engine that fits a model to a dataset. It manages the training, validation, and testing lifecycle: it iterates the training data in epochs, periodically evaluates on the validation split, computes metrics, and drives checkpointing and reporting through callbacks.
Usage
A trainer is built from a configuration and run with execute; see the
usage guide for a complete script.
from icegraph.trainer import Trainer
with Trainer.from_yaml(config_path) as trainer:
trainer.execute()
Configuration
The trainer configuration is an engine configuration (services, policy, and
components) plus a few run-level keys:
Option |
Description |
Type |
Default |
|---|---|---|---|
|
Directory where checkpoints, logs, and plots are written. |
path |
required |
|
Maximum number of training epochs. |
int |
required |
|
Number of epochs between validation passes. |
int |
required |
It uses the state, record, data, metrics, and decode services, a policy, and the full set of components (model, transformer, normalizer, optimizer, loss).
How it works
Each epoch runs the training split, updating the model through the optimizer against
the loss. Every val_interval epochs the trainer runs the validation split, where
it computes metrics and serves predictions to callbacks but performs no weight
updates. A final test pass evaluates the trained model. The run is reproducible
through the state service’s seed, and can be scaled across ranks with the
Distributed wrapper.