Batch Normalization Backward Correctness #
The training-time BatchNorm differential couples all positions in a channel through the channel
mean and variance. This file proves the reverse-mode rule used by TorchLean for an arbitrary
spatial shape. The proof is stated as JVP/VJP adjointness: pairing an input and parameter tangent
with the forward differential gives the same scalar as pairing the upstream gradient with
Spec.batchNormBackward.
The theorem is independent of a memory layout. The spatial shape is flattened only inside the BatchNorm definition, so the result covers vectors, images, volumes, and higher-rank tensors with one statement.
The companion module NN.Proofs.Autograd.Tape.Ops.Norm.BatchNormFDeriv proves that
Spec.batchNormJvp is the Fréchet derivative of Spec.batchNorm in (x, gamma, beta) whenever
0 < ε (hasFDerivAt_batchNorm, fderiv_batchNorm_eq_batchNormJvp). Together with the
adjointness below this identifies Spec.batchNormBackward as the adjoint of that derivative.
The normalized BatchNorm reverse rule is adjoint to its forward differential.
The rank-general BatchNorm reverse rule is adjoint to its forward differential.
This is the correctness theorem for the public channel-first operator. The spatial shape is arbitrary; flattening is an implementation detail used only to compute each channel's statistics. The conclusion accounts for the input tangent and both affine parameters.