xnn.common.train.graphed.GraphedStep#

class xnn.common.train.graphed.GraphedStep(body, device, warmup=3)[source]#

Bases: object

A training step on padded batches, captured once and replayed.

Parameters:
  • body (callable) – body(batch) -> (pred, logs, counts): the whole training step on a padded batch (forward, weighted_loss(sync=False), backward, gradient clipping, the optimizer and the weight average), with tensors in pred, logs and counts.

  • device (torch.device) – The training device.

  • warmup (int, optional) – Ordinary steps before the capture. Defaults to WARMUP_STEPS.