SGD, momentum, AdamW, and schedules
Use sgd, momentum, adamw, and schedules to move the neural networks production brief toward a defensible release.
A nonlinear sensor classifier defeats every classical baseline.
This lesson isolates sgd, momentum, adamw, and schedules as one decision inside that system. The people affected are product users and operators; the learning data must carry event time, availability time, ownership, and version; and the operating envelope is a declared latency, cost, and operator-capacity budget.
Choose whether and how to use chain rule at a declared prediction cutoff.
Measure decision utility alongside calibration, slice reliability, and system latency—not model score alone.
A nonlinear sensor classifier defeats every classical baseline. An unsafe release must degrade to a named baseline or the last known-good version.
Build the mental model before the machinery.
The core move is to treat sgd, momentum, adamw, and schedules as a contract between data, a computation, and an action. Package preprocessing, vocabularies, weights, calibration, output semantics, and batch-one parity as one artifact. The implementation becomes easier to debug once you can state which inputs exist, which state is learned, what output means, and what must remain invariant after serialization.
chain rule
Define it in a hand-checkable form and name the prediction-time inputs.
initialization
Connect it to the production metric and identify what it cannot guarantee.
AdamW
Stress it with a slice, a temporal boundary, and a failure-safe alternative.
dropout
Stress it with a slice, a temporal boundary, and a failure-safe alternative.
Lessons 1, 2, 3 in this course.
Name every symbol. Check every shape.
Backpropagated error is the central invariant for this lesson. The formula is useful only when its inputs match the production cutoff and its output maps to an action.
Backpropagated error
| Symbol | Meaning / shape / unit |
|---|---|
δ_l | loss gradient at layer l |
W | weight matrix |
φ′ | activation derivative |
Open derivation and numerical substitution
Start from the production quantity being optimized, substitute the observed values with their declared units, then isolate the model-controlled term. Preserve shape annotations at each step so broadcasting or aggregation cannot silently change the result.
- Write the named inputs: δ_l, W, φ′.
- Substitute one small, hand-checkable batch before vectorizing.
- Calculate an independent reference value and compare within a declared tolerance.
# equation → code contract
inputs = validate_shapes_and_units(batch)
value = compute_c09(inputs)
assert is_finite(value)Calculate it small. Shape it realistically. Break it on purpose.
A result you can reproduce on paper
Solve XOR with two hidden units and watch the representation become linearly separable.
- Write every input and unit.
- Substitute values into the backpropagated error equation above.
- Compare the result to one simple baseline and explain the direction of the difference.
The same reasoning under real constraints
Combine telemetry with categorical embeddings to predict whether an incident breaches its SLO.
The production record includes the data snapshot, transformation state, artifact identity, cutoff, score, decision, and the version of the policy that consumed it.
The attractive result you should reject
An excessive learning rate causes NaNs; dead ReLUs and a BatchNorm train/eval mismatch hide the cause.
Diagnostic: replay the smallest failing slice from immutable inputs, then compare each boundary rather than retuning the model.
Change one assumption and make the tradeoff visible.
This lab runs predefined TypeScript only. It never executes learner code. Use the slider, numeric input, reset, live text, or table—the computation is the same.
Optimizer stability lab
Sweep learning rate over a deterministic convex-plus-curvature loss.
Assumption: Twenty gradient steps from w=4 on L(w)=w²/2.
Open nonvisual data table
| Item | Computed state | Interpretation |
|---|---|---|
| step 1 | 3.5200 | 6.19520 |
| step 5 | 2.1109 | 2.22801 |
| step 10 | 1.1140 | 0.62050 |
| step 15 | 0.5879 | 0.17281 |
| step 20 | 0.3103 | 0.04813 |
Trace the complete operating path.
- 01
Validate and version chain rule.
- 02
Compute sgd, momentum, adamw, and schedules from prediction-time-safe inputs.
- 03
Persist model, feature, and configuration identities together.
- 04
Serve or materialize behind explicit a declared latency, cost, and operator-capacity budget.
- 05
Join telemetry to mature outcomes and retain a rollback path.
Observability
Join service health, input quality, prediction distributions, slice behavior, and mature outcomes by exact version.
Cost
Measure storage, preprocessing, compute, queueing, and human review under a representative arrival pattern.
Failure modes
An excessive learning rate causes NaNs; dead ReLUs and a BatchNorm train/eval mismatch hide the cause. Add a detector, owner, mitigation, and stop condition for this class of failure.
Alternatives
Compare a rule, a simpler statistical baseline, and a different system boundary before adding model complexity.
Explain the contract, not just the vocabulary.
Network from first principles
Specify a NumPy MLP, finite-difference checks, PyTorch parity, calibrated inference, and debugging report.
- Forward/backward derivation
- Gradient check plan
- Optimizer/regularization ablations
- Export and batch-one parity
Read primary material with a purpose.
Return to the opening failure.
Package preprocessing, vocabularies, weights, calibration, output semantics, and batch-one parity as one artifact.
For this lesson, the release evidence is a hand-checked formal result, deterministic simulation output, a ≥80% checkpoint, the production rubric, and a named fallback. The course resolves when the system can produce a small network built from forward pass through backpropagation and optimization.