InformationWriter#
- class InformationWriter(log_frequency=1, step_offset=0)[source]#
Bases:
HookBaseAssemble per-step console logs and write scalar train metrics.
The primary training logger. In
before_stepit seeds the sharedcomm_info["iter_info"]string with the epoch/iteration position. Inafter_stepit filters the model output dict down to scalar-like entries (dropping large tensors such as logits/masks andmatch_*keys, and mappingtotal_losstoloss), records them intrainer.storage, appends them plus the current learning rate to the iteration log, emits that line to the logger everylog_frequencyglobal steps (and always on the last iteration of an epoch), and mirrors each scalar to the writer undertrain_batch/*(withparams/lr). Inafter_epochit logs the epoch-average of each tracked key undertrain/*. Registered asInformationWriter.- Parameters:
log_frequency (int) – Emit the assembled console line every this many global steps (coerced to at least
1). Writer scalars are logged every step regardless. Defaults to1.step_offset (int) – Constant added to the computed global step, e.g. to continue a warm-started run’s W&B x-axis from where the parent checkpoint left off. Defaults to
0.
Note
Writer scalars are only emitted when
trainer.writeris notNone. The global step is computed to match the other logging/diagnostic hooks so all curves share an x-axis.Example
Add to
cfg.hooks; it is the main per-step logger — it records the scalar model outputs and learning rate and mirrors them to the writer:hooks = [dict(type="InformationWriter", log_frequency=20)] # → every step writes "train_batch/<key>" for each scalar loss/metric # and "params/lr" to the writer; emits the assembled console log line # every 20 steps; in after_epoch writes the "train/<key>" epoch averages