Normalization analysis properties #
This file proves algebraic properties of normalization and cosine loss over ℝ. The executable
definitions live in NN.Spec.Layers.Normalization and NN.Spec.Layers.Loss.
Current focus:
- BatchNorm inference is affine in the input
xwhen the running statistics are fixed. - Scaled cosine loss and its selected gradient preserve the epsilon-clipped real formulas.
That fact matters because inference-time BatchNorm can be folded into a preceding/following affine layer for verification, bound propagation, and simplification. Training-mode BatchNorm has batch-dependent statistics and is not claimed by this theorem. The folding identity is over real arithmetic; it does not justify reordering finite-precision division, multiplication, and addition without a separate rounding analysis.
BatchNorm inference is affine #
At inference time, BatchNorm uses fixed running mean/variance. The resulting function is affine:
$y=x\odot\operatorname{scale}+\operatorname{bias}$.
Inference-time BatchNorm is affine in the input x.
batchNormInference x runningMean runningVar gamma beta epsilon
equals the pointwise affine map
$x\,\frac{\gamma}{\operatorname{std}} +\left(\beta-\mu\frac{\gamma}{\operatorname{std}}\right)$
after broadcasting channel parameters to the input shape and clamping the running variance exactly as the spec does.
Scaled cosine normalization #
Scaling before normalization preserves the epsilon-clipped real cosine loss. This identity does not assert bitwise equivalence of the two floating-point schedules.
The scaled pullback preserves the clipped real formula, including its zero radial term at and below the predicted-norm floor. No rounding-error bound is asserted here.