Trainer#
- class Trainer(cfg)[source]#
Bases:
TrainerBaseDefault single-dataset supervised/SSL trainer.
Builds everything from one
cfg(model, train/val/test loaders, optimizer, scheduler, AMP scaler, hooks, writer, and the parallel context) and runs the standard AMP forward/backward optimization step inrun_step(). The train loop is resume-aware: it restoresstart_epoch/start_iterand the global step from checkpoint hooks, re-aligns metric writers and the dataloader cursor, and treatscfg.epochas the absolute horizon so a run can be extended without changing schedules. Registered asDefaultTrainer– select viatrain = dict(type="DefaultTrainer")(the default).- Parameters:
cfg – Fully-resolved run config providing
save_path,epoch,resume, themodel/data/optimizer/scheduler/hookssub-configs, and the distributed/AMP settings.