← All publications

Walsh-Hadamard Variational Inference for Bayesian Deep Learning

  • Bayesian Deep Learning
  • Variational Inference

We parameterize correlated weight distributions through Walsh-Hadamard transforms, reducing variational storage and the cost of matrix-vector products.

Paper NeurIPS 2020

Simone Rossi1, Sébastien Marmin1, Maurizio Filippone1

  1. EURECOM

Large neural networks create a difficult variational inference problem: storing a distribution over every weight is expensive, and the accumulated KL penalty can dominate the data-fitting objective. Walsh-Hadamard Variational Inference (WHVI) addresses these costs through a structured distribution over weight matrices.

A structured stochastic weight matrix

For a square layer of width DD, WHVI represents a sampled weight matrix as

W=S1Hdiag⁡(g)HS2,g∼q(g),W=S_1H\operatorname{diag}(g)HS_2, \qquad g\sim q(g),

where HH is a Walsh-Hadamard matrix, S1S_1 and S2S_2 are learned diagonal matrices, and gg contains the stochastic coordinates. The construction adapts structured random-matrix factorizations used in kernel approximations to posterior inference.

With a diagonal Gaussian distribution over gg, the stochastic representation uses O(D)O(D) parameters. Multiplication by the dense matrix WW is implemented through diagonal operations and fast Walsh-Hadamard transforms, giving O(Dlog⁡D)O(D\log D) cost. An unrestricted dense layer instead requires O(D2)O(D^2) storage and multiplication.

Correlations from shared coordinates

The entries of WW depend on the same random vector gg. Consequently, even independent coordinates in gg induce correlations between network weights. For Gaussian q(g)q(g), the induced weight distribution is Gaussian with a structured covariance.

Diagonal covariance over the stochastic coordinates and induced covariance over vectorized network weights
A diagonal covariance over gg (left) produces a correlated covariance over the vectorized weight matrix (right). The shared Walsh-Hadamard factors determine this dependence.

The representation restricts the weight distribution to a structured family. Its reduced parameter count changes the variational approximation and the regularization associated with its stochastic coordinates. The learned diagonal factors control how those coordinates are expressed across the weight matrix.

Training with fast transforms

We derive weight and local reparameterizations for stochastic-gradient optimization of the evidence lower bound. Local reparameterization samples layer outputs rather than a complete weight realization, providing another way to estimate the training objective.

Padding, concatenation, and reshaping extend the factorization to rectangular matrices and parameter vectors. Normalizing flows over gg provide a richer, non-Gaussian family while retaining the structured matrix multiplication.

Predictive quality and computational cost

We evaluate regression, image classification, and convolutional architectures, comparing predictive error and log-likelihood, parameter counts, and computational costs with mean-field and other approximate Bayesian methods. Comparisons with alternative diagonal-transform factorizations and tensor factorizations isolate the effect of the chosen weight representation.

In these comparisons, the structured family offers competitive predictive performance with reduced inference costs. Its computational advantage follows from the shared stochastic coordinates and fast transforms. The same factorization determines which posterior means and dependencies the approximation can express.