Training Dynamics, Regularization & Diagnosis

A working model is not enough. You need controls that distinguish an objective, optimization, data, mode, numerical or capacity failure before changing the configuration.

Section 3 of 8 · 8 units · about 35 hours

0/8

By the end you can Given an unfamiliar failing compact run, choose a discriminating control, repair the causal defect, add a regression test, and defend the configuration with activation, gradient, update and generalization evidence across two seeds.

Units

Build it

Mini project · about 10 to 14 hours

Seeded-fault diagnosis of a compact run

Instrument a small MLP or CNN trained with your section 2 trainer, inject faults you do not choose yourself, and diagnose each with a discriminating control, a repair, a regression test and evidence across two seeds. Finish by defending one configuration with measurements.

  1. 1Instrument the run: per-layer activation mean and std, dead or saturated fractions, gradient norms, update-to-weight ratios, loss, and train and validation metrics, logged per step.
  2. 2Run the controls first and keep them as tests: overfit one fixed batch to near-zero loss, and train on shuffled labels until training accuracy rises while held-out accuracy stays at chance.
  3. 3Write a fault script that applies one fault from a seeded list and seals the choice until diagnosis is committed. Cover a softmax before CrossEntropyLoss, missing zero_grad, eval mode left on, an excessive learning rate, bad init scale and augmented validation data.
  4. 4Diagnose three injected faults. For each, write rival hypotheses first, run one control that separates them, repair, and add a regression test that fails on the fault and passes on the repair.
  5. 5Compare SGD with momentum and AdamW with decoupled weight decay at matched budgets, with warmup, a cosine schedule and gradient clipping, across two seeds.
  6. 6Check gradient accumulation: micro-batches of size match one batch of size times within tolerance for a model without batch normalization or dropout, and show what breaks when the loss is not divided by .
What you hand in
  • The instrumented trainer, the control tests and the fault script.
  • Three postmortems, each with symptom, rival hypotheses, discriminating control, repair, regression test and one limitation.
  • A configuration defense: two-seed curves with activation, gradient, update and validation evidence for the chosen optimizer and schedule.
How to check it
  • Self-grade with the rubric below
How it's graded

Controls

Pass: The fixed batch reaches near-zero loss, and shuffled labels leave held-out accuracy at chance.

Great: Both run as automated CPU tests.

Diagnosis

Pass: Each of three faults is found with a stated discriminating control.

Great: Each postmortem names at least two rival hypotheses and shows why the control separates them.

Regression guards

Pass: Each repair has a test that fails on the fault.

Great: The tests run on both seeds and check a mechanism, such as a norm, a mode flag or a reduction, not only the final loss.

Configuration evidence

Pass: Two seeds for the chosen configuration, with activation, gradient and update statistics.

Great: Update-to-weight ratios and the validation gap support the chosen learning rate and decay against one rejected alternative.

Accumulation

Pass: Accumulated gradients match the large batch within a stated tolerance.

Great: You also show the mismatch caused by an undivided loss and explain why batch normalization breaks exact equivalence.

Resources