Overlapping windows add their gradients
symbolic▲▲▲Exact integers and fractions where possible; six decimals otherwise.
STATEMENT
Derive and check the kernel, input and bias gradients of I.11.B01.
GIVEN
Use I.11.B01’s and . The upstream derivative is
Define the scalar objective . Treat as fixed during differentiation.
FIND
The gradient formulas and their complete numerical arrays.
STRATEGY
Differentiate one forward product, then sum every occurrence of each shared weight or overlapping input. Confirm the result using central differences.
SOLUTION
The differential of one output is
Multiplying by and summing gives (I.11.3). For the kernel entries, the sums are
The bias derivative is . For the input, scatter each into its corresponding window and add overlaps:
The centre illustrates why assignment is wrong. Its four contributions are , , and , whose sum is one.
The forward objective is . With zero bias, the map is linear in while is fixed, and linear in while is fixed. Consequently,
These dot products are useful independent checks. The script also perturbs every input, weight and bias by and compares central differences to the analytic result within . Additional tests use padding, stride and dilation, where the same scatter-add rule must follow a different index map.
Answer
, and .
Check — sanity
The input-gradient shape matches and the weight-gradient shape matches . All three occurrences of a nonzero centre contribution are retained.
Where this breaks
This is the derivative of the stated cross-correlation. Introducing another kernel flip while scattering would compute a different derivative. A nonlinear activation after the convolution must be differentiated first.
Variation
If the loss is averaged over the four outputs rather than summed, divide every upstream entry by four. All three gradient arrays scale accordingly; do not divide the already-scaled gradients again.