DVPApplied Creative AI Engineering

Search this course

Search lesson and reference material.

↑ ↓ to choose · Enter to open · Esc to close

Reference

PyTorch lifecycle field guide

The compact training, evaluation, checkpoint, and device loop.

A compact lookup for the baseline lab.

Training batch

  1. model.train() once per training phase.
  2. Move model, features, and labels to one device.
  3. optimizer.zero_grad().
  4. logits = model(features).
  5. loss = loss_fn(logits, labels).
  6. loss.backward().
  7. optimizer.step().

Evaluation batch

Use model.eval() and with torch.no_grad():. The first changes layer behavior; the second disables gradient recording.

Reproducible checkpoint

Save model and optimizer state dictionaries, epoch, seed, config, ordered labels, dataset checksum, preprocessing/weights identity, and best validation metric. Load with an explicit map_location. Recreate the model and optimizer before restoring state.

Device triage

Start with a CPU one-batch shape test. On GPU, record PyTorch/CUDA/device versions and reduce batch size before changing the model. Reproduction means matching inputs and configuration within a declared tolerance, not promising bitwise identity across hardware.

Notes

Your local study notes mount here when JavaScript is available.

Protected AI Tutor

Teaching modes mount here when JavaScript is available. The readable course remains available without them.