espnet3.components.callbacks.default_callbacks.MetricsLogger
espnet3.components.callbacks.default_callbacks.MetricsLogger
class espnet3.components.callbacks.default_callbacks.MetricsLogger(log_every_n_steps: int = 500)
Bases: Callback
Log compact train and validation metric summaries.
This callback owns the human-readable metric logging for the default ESPnet3 training loop. It handles three reporting points in one place.
- interval-based training batch summaries
- end-of-epoch training summaries
- end-of-epoch validation summaries
The goal is to keep logging responsibility in a single callback instead of splitting train and validation reporting across separate callback classes.
- Parameters:log_every_n_steps – Number of training steps between batch-summary log lines.
- Returns: None.
- Raises:None. –
Notes
- Training summaries remove the train/ prefix from logged metrics.
- Validation summaries remove the valid/ prefix from logged metrics.
- Validation sanity-check runs are ignored to avoid noisy startup logs.
Examples
>>> cb = MetricsLogger(log_every_n_steps=200)
>>> trainer = Trainer(callbacks=[cb, ...])Example train log output. 20epoch🚋4201-4400batch: iter_time=6.212e-05, loss=46.669
Example validation log output. epoch_summary:20epoch:valid: valid_time=1.42, acc=0.91, loss=0.83
Initialize the logger with a reporting interval.
on_after_backward(trainer, pl_module)
Record backward time.
on_after_optimizer_step(trainer, pl_module)
Record optimizer step time.
on_before_backward(trainer, pl_module, loss)
Mark the end of forward pass and start backward timing.
on_before_optimizer_step(trainer, pl_module, optimizer)
Start optimizer step timing.
on_train_batch_end(trainer, pl_module, outputs, batch, batch_idx)
Aggregate metrics and emit a summary line when due.
on_train_batch_start(trainer, pl_module, batch, batch_idx)
Start timers for a training batch.
on_train_epoch_end(trainer, pl_module)
Reset buffers at the end of each training epoch.
on_validation_epoch_end(trainer, pl_module)
Emit one log line with aggregated validation metrics.
on_validation_epoch_start(trainer, pl_module)
Start wall-clock timing for one validation epoch.
