Exact Gaussian Moment Matching for Residual Networks: a Second-Order Method

Simon Kuang, Xinfan LinNeurIPS 2026

TL;DR

What happens when you feed a cloud of uncertainty—specifically, a multivariate Gaussian distribution—into a deep neural network instead of a single data point? Rather than relying on slow, brute-force Monte Carlo simulations or rough approximations that ignore how neurons correlate, this paper derives exact, closed-form mathematical expressions to track the mean and full covariance through both standard and residual layers. The result is a fast, deterministic method that slashes estimation errors by up to thousands of times compared to standard baselines.

What Problem Does This Paper Address?

Imagine you have a neural network, and your input isn't a crisp, noiseless vector, but a fuzzy probability distribution. Knowing the exact shape of the output distribution is crucial for real-world tasks: testing how robust a model is to noisy sensors, doing Bayesian deep learning, or estimating risk in AI safety.

Because calculating the exact output distribution of a deep network is NP-hard, engineers usually fall back on Monte Carlo sampling—throwing thousands of random samples through the network and measuring where they land. That works, but it is computationally exhausting and scales terribly as dimensions grow.

The faster alternative is moment matching: assume the distribution stays roughly Gaussian at each layer, and just track its center (mean vector $\mu$) and spread/correlations (covariance matrix $\Sigma$) layer by layer. Historically, however, the math for passing a full covariance matrix through nonlinear activations was deemed intractable. Prior work had to compromise by assuming the input variance was tiny, assuming the mean was zero, ignoring off-diagonal correlations between neurons ("mean-field" assumptions), or skipping residual (bypass) connections altogether.

Assumptions imposed by previous Gaussian approximation methods compared to this paper.

Methods

Kuang and Lin refuse to make those simplifying assumptions. Instead, they tackle the math head-on to derive exact, closed-form analytical expressions for the post-activation mean and full covariance matrix given an unrestricted multivariate Gaussian input.

  • What's standard: Layer-by-layer Gaussian moment matching—approximating each hidden layer's output as a Gaussian before passing it to the next layer.
  • What's new: Using novel integral and differential identities of the Gaussian function, the authors solve the exact off-diagonal covariance equations for probit, GeLU, and sine activation functions. Better yet, by taking mathematical limits, they also get exact formulas for ReLU (as a limit of GeLU) and Heaviside step functions (as a limit of probit).
  • Residual architectures: Because they include the identity function in their cross-covariance math, their method naturally handles generalized residual layers (skip connections)—a staple of modern architectures that previous exact methods couldn't touch.
  • Theoretical certification: Beyond the formulas, they use a smooth fourth-order probability distance metric to prove that exact moment matching acts as a true second-order method, canceling out leading low-variance errors that plague simpler linearization techniques.

Datasets

Based on the provided text and figures, the authors evaluate their method on synthetic random neural networks (tested across small and large input variance scenarios) and a variational Bayes neural network benchmarked against Monte Carlo ground truth. Specific external dataset names (e.g., UCI, MNIST) are not discussed in the provided excerpt of the paper.

Key Insights and Ideas

  • Correlations between neurons matter—a lot: Setting off-diagonal covariances to zero (the mean-field assumption) throws away vital structural information about how signals co-vary inside a network, especially when variances are large or skip connections are present.
  • ReLU and Heaviside via smooth limits: Nondifferentiable activations like ReLU are notoriously annoying for Taylor-series-style approximations. Viewing ReLU as the mathematical limit of GeLU (and Heaviside as the limit of probit) unlocks exact closed-form moments without needing smooth approximations during inference.
  • Higher-order accuracy compounds gracefully: Linearizing a network (the "delta method") leaves behind low-variance errors at every single layer. Exact moment matching cancels these leading error terms, and the authors prove this local accuracy cleanly composes across deep multi-layer stacks.
Figure 4.1: Empirical small-covariance convergence for a fixed deep sine network. Methodology is described in Appendix I.

Key Results

The authors measure accuracy by comparing their predicted output distributions against brute-force Monte Carlo ground truth using Kullback-Leibler (KL) divergence (lower is better):

  • Massive gains on random networks: On large-variance random neural networks, their exact analytic method achieves median KL-divergence improvements ranging from tens to thousands of times better than common baselines (such as mean-field, linear/delta method, and unscented transforms).
  • Variational Bayes speedup/accuracy: When applied to a variational Bayes neural network, the method beats a state-of-the-art deterministic inference baseline by an order of magnitude in KL divergence.
  • Asymptotic scaling: As input covariance shrinks (from $10^{-1}$ down to $10^{-8}$), empirical tests on deep sine networks confirm that the analytic method's error plunges orders of magnitude faster than standard linearization, reaching down to $10^{-14}$ KL divergence where linear methods stall around $10^{-8}$.
Figure 5.1: Comparison of goodness of approximation (lower KL divergence is better) for all ran- dom neural networks, grouped by approximation method, in the small (left) and large (right) input variance scenarios. Four non-finite results are omitted in each scenario.

Limitations and Future Work

  • The Gaussian bottleneck: Even though the mean and covariance are calculated exactly for a single layer given a Gaussian input, the true post-activation distribution of a nonlinear layer is no longer strictly Gaussian. Re-approximating it as Gaussian at each step in a deep network remains an inherent structural approximation.
  • Regularity assumptions for bounds: Their theoretical smooth-distance error bounds rely on regularity assumptions (which hold neatly for smooth activations like sine, probit, and GeLU, though sharp kinks like ReLU require careful treatment).
  • Activation coverage: While GeLU, ReLU, probit, Heaviside, and sine cover a massive swath of modern deep learning, activations without known closed-form Gaussian integrals (like the exact logistic sigmoid without probit rescaling, or softmax/attention mechanisms) remain outside this exact catalog.

Summary updated

Abstract

We study the problem of propagating the mean and covariance of a general multivariate Gaussian distribution through a deep (residual) neural network using layer-by-layer moment matching. We close a longstanding gap by deriving exact moment matching for the probit, GeLU, ReLU (as a limit of GeLU), Heaviside (as a limit of probit), and sine activation functions; for both feedforward and generalized residual layers. On large-variance random networks, median KL-divergence improvements over common baselines range from tens to thousands of times. On a variational Bayes neural network, we show that our method improves upon a state-of-the-art deterministic inference method by an order of magnitude in KL divergence from Monte Carlo ground truth. We also give a smooth-distance error bound showing that, under regularity assumptions, moment matching removes the leading low-variance errors and propagates higher-order local accuracy through the layers of a network.
BibTeX
@inproceedings{kuang2026exact,
  author = {Simon Kuang and Xinfan Lin},
  title = {{Exact Gaussian Moment Matching for Residual Networks: a Second-Order Method}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=1dsxDeHdpR},
}
Figure