← All publications

Model Selection for Bayesian Autoencoders

  • Bayesian Deep Learning
  • Generative Modeling
  • Uncertainty Quantification

We select Bayesian autoencoder weight priors by matching their output distributions to data, then combine posterior sampling with latent density estimation for generation.

Paper NeurIPS 2021

Ba-Hien Tran1, Simone Rossi1, Dimitrios Milios1, Pietro Michiardi1, Edwin V. Bonilla2, Maurizio Filippone1

  1. EURECOM
  2. CSIRO's Data61, Australian National University & University of Sydney

A Bayesian autoencoder (BAE) places uncertainty over its encoder and decoder weights, making the weight prior a central modeling choice. We choose that prior by matching the distribution of its outputs to reference images, then infer the weights and fit a density model in the learned latent space. Across small image datasets, this improves reconstruction scores and generated samples relative to standard weight priors and several autoencoder baselines.

Making prior knowledge visible

The nonlinear encoder–decoder mapping makes a Gaussian weight prior difficult to interpret. Standard normal weights produce noise-like images; optimized priors produce recognizable structure, including for out-of-distribution inputs.

MNIST and CelebA outputs under standard Gaussian and optimized weight priors, including out-of-distribution inputs
Prior output samples for digits and faces. Matching the output distribution changes the prior's image structure before posterior inference, making its inductive bias directly inspectable.

We use independent Gaussian weights and biases, sharing their means and variances within each layer ll:

p(wl)=N(wl;μlw,σlw2),p(bl)=N(bl;μlb,σlb2).p(w_l)=\mathcal N(w_l;\mu_{l_w},\sigma_{l_w}^2), \qquad p(b_l)=\mathcal N(b_l;\mu_{l_b},\sigma_{l_b}^2).

These layerwise parameters form ψ\psi. Reparameterized samples let gradients reach ψ\psi through both networks and the observation likelihood. For reconstruction, the targets y\mathbf y equal the inputs x\mathbf x. We write distributions over reconstruction targets with conditioning on these inputs left implicit.

Our functional-prior study matches neural-network function samples to a Gaussian-process prior.

Matching distributions through one-dimensional projections

Empirical Bayes motivates selecting ψ\psi through the marginal pψ(y)p_\psi(\mathbf y), which integrates over weights and network outputs. For a fixed data distribution π\pi, maximizing expected log marginal likelihood is equivalent to minimizing Kullback–Leibler (KL) divergence:

arg⁡max⁡ψEπ[log⁡pψ(y)]=arg⁡min⁡ψKL⁡[π∥pψ].\arg\max_\psi\mathbb E_{\pi}[\log p_\psi(\mathbf y)] = \arg\min_\psi\operatorname{KL}[\pi\|p_\psi].

Both density evaluation and empirical KL estimation are difficult here. We use distributional sliced-Wasserstein distance as a sample-based surrogate:

ψ⋆=arg⁡min⁡ψDSW2(pψ,π),DSW2(pψ,π)=sup⁡σ∈MC[Eθ∼σW22 ⁣(Rpψ,Rπ)]1/2.\begin{aligned} \psi^\star&=\arg\min_\psi DSW_2(p_\psi,\pi),\\ DSW_2(p_\psi,\pi) &=\sup_{\sigma\in\mathbb M_C} \left[\mathbb E_{\boldsymbol\theta\sim\sigma} W_2^2\!\left(\mathcal R p_\psi,\mathcal R\pi\right) \right]^{1/2}. \end{aligned}

Here R\mathcal R projects each distribution along the unit direction θ\boldsymbol\theta, and W2W_2 measures the Wasserstein distance between the resulting one-dimensional distributions. The admissible direction distributions MC\mathbb M_C satisfy a constraint, controlled by CC, that encourages directional diversity. Sorting projected samples gives the one-dimensional transport cost. A learned mapping searches for informative directions while the prior parameters minimize their discrepancy. Model samples include likelihood noise after the autoencoder output. The implementation uses 1,000 projections and 32 prior weight samples per input.

Posterior inference and latent density estimation

After prior optimization, stochastic gradient Hamiltonian Monte Carlo approximates the weight posterior. We retain 32 samples after burn-in and thinning. To generate images, we fit a Dirichlet process mixture pϑ(z)p_\vartheta(\mathbf z) to posterior-mean encoder representations. Its mixture complexity adapts to the data. Generation then uses

znew∼pϑ(z),fnew=Ep(wdec∣y)[fdec(znew;wdec)].\mathbf z_{\mathrm{new}}\sim p_\vartheta(\mathbf z), \qquad \mathbf f_{\mathrm{new}} =\mathbb E_{p(\mathbf w_{\mathrm{dec}}\mid\mathbf y)} [f_{\mathrm{dec}}(\mathbf z_{\mathrm{new}};\mathbf w_{\mathrm{dec}})].

This supplies an explicit sampling distribution over latent codes and averages decoder uncertainty when producing an image.

Two-dimensional MNIST latent representations compared with samples from latent priors or fitted density estimators
With 1,000 MNIST training images and two latent dimensions, gray points show test representations and red points show prior or density samples. The fitted mixtures cover the BAE representations, illustrating the role of latent density estimation in generation.

Transferring information through the prior

On MNIST, 100 zero digits specify the prior, while posterior inference uses digits one through nine. On Frey–Yale, 1,956 Frey faces specify the prior and Yale faces support inference. These settings test information transfer separately from pooling both datasets for training.

Reconstructions, generated digits and faces, and pixelwise posterior standard deviations for MNIST and Frey–Yale
The optimized prior supports reconstruction of zero digits absent from posterior training and transfers facial structure from Frey to Yale. The final row shows pixelwise standard deviations. Stars identify baselines trained on the union of inference and prior-selection data.
Test predictive log-likelihood across training-set sizes and MNIST latent dimensions
Reconstruction log-likelihood improves with the optimized prior across the displayed data budgets and latent dimensions. Gains are larger with fewer observations; the right-hand comparison varies the bottleneck size.

Generating faces with limited observations

CelebA experiments reserve 1,000 images for prior selection and use 500–4,000 for inference, with four random splits. Images have 64×6464\times64 resolution and typically 50 latent dimensions. Predictive reconstruction log-likelihood measures reconstruction and uncertainty; Fréchet Inception Distance (FID) evaluates generated-image distributions using 10,000 samples. DiffAugment-GAN achieves lower mean FID at every tested budget; that baseline also uses StyleGAN2 and differentiable augmentation.

CelebA reconstructions, generated faces, predictive log-likelihood and FID across four training budgets
With a continuous Bernoulli likelihood, the optimized BAE improves reconstruction scores and achieves lower FID than the displayed autoencoder and NS-GAN baselines. Markers and bars summarize means and standard deviations; pictured BAE results use 500 inference images.
Generated CelebA faces with a truncated Gaussian likelihood and FID scores for six autoencoder methods
Replacing continuous Bernoulli with truncated Gaussian reduces color saturation. At 500 inference images, optimized-prior BAE achieves FID 62.75±3.6162.75\pm3.61, versus 84.11±4.0984.11\pm4.09 for the standard-prior BAE. Prior optimization improves the comparison under both tested likelihoods.

Prior selection and posterior tempering

MNIST ablations distinguish changing prior structure from increasing likelihood weight through posterior tempering. At temperature τ>0\tau>0, tempering raises the likelihood to the power 1/τ1/\tau while retaining the prior. The optimized prior retains predictive variation as reference data increase, and its best tested reconstruction score occurs at τ=1\tau=1, the ordinary Bayesian posterior.

MNIST predictive variance as prior-selection data increase or the posterior temperature decreases
Orange uses more images to select the prior; blue increases the likelihood's effective data count through tempering. Variance decreases more sharply under tempering, separating its uncertainty behavior from prior optimization.
MNIST test reconstruction log-likelihood versus temperature for standard and optimized priors
The standard prior benefits most at τ=0.1\tau=0.1, while the optimized prior reaches its best displayed score at τ=1\tau=1. The MNIST comparison distinguishes changes to the prior from changes to the likelihood's weight in the posterior.