What breaks when backpropagation forgets a path?
Run on Molab
- Download the notebook.
- Open Molab (opens in a new tab), sign in, and import the downloaded Python notebook.
- Write a prediction, run the reference, then change one condition. These small experiments run on CPU.
Your notebook runs in your Molab workspace. Download its report to keep your evidence.
This experiment follows the shared-variable computation in From derivatives to backpropagation. You need the product rule and the idea that changing one input can affect an output through several paths.
The forward computation is , followed by . The same appears inside the sum and as a multiplication input. We will deliberately omit a backward contribution while preserving the complete forward computation. This is a diagnostic experiment, not a replacement forward model.
Establish a reference
Use , , both backward paths, and difference step . Predict the forward output and the total derivative with respect to . Record your reasoning, then run the reference.
The bench also computes a central difference, , with fixed. Treat it as an independent numerical check, not an exact oracle at every step size.
Remove one backward contribution
Keep , , and fixed. Select , predict the gradient and forward output, and record a run. Then select and repeat the comparison.
Record both path contributions, the reported gradient, and its discrepancy from the finite-difference estimate. Does an unchanged forward result guarantee that the backward calculation is correct?
Experiment bench
Forward computation: a = x + y, z = a × x. The backward-path setting changes only the reported gradient. Central differences always evaluate the complete forward function with y fixed.
Load the reference, write a prediction, and run it first. For each comparison, change only the condition named in the lesson. Each run is calculated here in your browser.
Loading reference settings preserves your evidence. Work is saved in this tab across navigation and reloads. Download your report to keep it after closing the tab.
Build your explanation from the evidence
Explain which dependence was lost in each modified run before opening the calculation.
Compare the paths
At , and . The direct multiplication input contributes ; the route through contributes . Adding them gives 7. Keeping only one path gives 5 or 2, even though the forward output remains 10 in both cases.
Expanding gives . It agrees with . A central difference is exact for this quadratic in exact arithmetic, but the computer evaluates rounded numbers.
Design a test that could miss the bug
Choose inputs for which omitting one path would produce the right numerical gradient by accident. State which contribution you expect to vanish, then test your case. Keep .
Next choose a second input that exposes the same omission. Explain why a gradient check at just your first point would provide weak evidence about the implementation.
As a separate numerical experiment, restore the reference and both paths. Change only through , , , and . Predict whether the smallest step must give the best check, then compare the recorded discrepancies. Distinguish a small nonzero rounding discrepancy from an estimate that collapses to zero.
For your independent comparisons, use to select a recorded run that differs in only the condition you are testing.
Report and transfer
Distinguish an omitted derivative contribution from a finite-difference rounding error. Use at least two input points in your explanation and state which settings stayed fixed in each comparison.
On paper, consider . Both multiplication inputs refer to the same variable. Should a backward pass process one contribution or two? Predict the result of accidentally keeping only one, then explain how you would detect the mistake.
Check your diagnostic reasoning
At , the contribution through the sum vanishes. At , the direct contribution vanishes. An implementation that omits that contribution can pass a check at such a point and fail elsewhere. At , adding or subtracting can round back to the same representable input, making the difference estimate zero despite a nonzero derivative.
For , two operand edges refer to the same variable. Each contributes , so the total derivative is . Deduplicating the variable must not discard one of its edge contributions.
Continue experimenting
Previous: When does a larger learning rate stop helping? · Next: What changes when we remove the hidden activation? · All machine learning experiments