$\pi$VAE: Encoding stochastic process priors with variational autoencoders

Swapnil Mishra, Seth Flaxman, Samir BhattarXiv 2020

Abstract

Stochastic processes provide a mathematically elegant way model complex data. In theory, they provide flexible priors over function classes that can encode a wide range of interesting assumptions. In practice, however, efficient inference by optimisation or marginalisation is difficult, a problem further exacerbated with big data and high dimensional input spaces. We propose a novel variational autoencoder (VAE) called the prior encoding variational autoencoder ($\pi$VAE). The $\pi$VAE is finitely exchangeable and Kolmogorov consistent, and thus is a continuous stochastic process. We use $\pi$VAE to learn low dimensional embeddings of function classes. We show that our framework can accurately learn expressive function classes such as Gaussian processes, but also properties of functions to enable statistical inference (such as the integral of a log Gaussian process). For popular tasks, such as spatial interpolation, $\pi$VAE achieves state-of-the-art performance both in terms of accuracy and computational efficiency. Perhaps most usefully, we demonstrate that the low dimensional independently distributed latent space representation learnt provides an elegant and scalable means of performing Bayesian inference for stochastic processes within probabilistic programming languages such as Stan.

Introduction

Stochastic processes, such as Gaussian Processes (GPs), are considered the "gold standard" for modeling uncertainty in functions. However, they face a significant scalability wall: standard GPs require matrix inversions that scale cubically ($O(n^3)$) with the number of data points. Furthermore, performing full Bayesian inference on these models often involves navigating complex, high-dimensional posterior landscapes, which makes Markov Chain Monte Carlo (MCMC) sampling computationally prohibitive for large datasets.

While Variational Autoencoders (VAEs) are excellent at learning compressed representations of data, they are typically not valid stochastic processes as they cannot easily handle arbitrary input locations or guarantee mathematical consistency across different sets of observations. This paper introduces the $\pi$VAE (prior encoding variational autoencoder), a framework that bridges the gap between the flexibility of deep learning and the rigor of Bayesian stochastic processes.

Methodology: The $\pi$VAE Architecture

The core innovation of the $\pi$VAE is inspired by the Karhunen-Loève expansion, which represents a stochastic process as a linear combination of basis functions: $f(s) = \sum \beta_j \phi_j(s)$. The $\pi$VAE implements this using a two-stage approach:

  1. Prior Training: The model learns a trainable feature mapping $\Phi(s)$ (acting as basis functions) and a VAE that encodes and decodes the weights $\beta$. It is trained on samples drawn from a target prior (e.g., a GP). Crucially, by defining the function as $f(s) = d(Z)^T \Phi(s)$, where $d(Z)$ is the VAE decoder, the authors prove that $\pi$VAE is a valid stochastic process—finitely exchangeable and Kolmogorov consistent.
  2. Inference: Once trained, the encoder is discarded. The decoder $d(Z)$ serves as a fixed, low-dimensional prior. Bayesian inference is then performed by sampling the latent variable $Z$ (typically $<50$ dimensions) using MCMC. Because $Z$ is low-dimensional and approximately uncorrelated (thanks to the VAE's KL-divergence penalty), the MCMC sampler is incredibly efficient.
The training procedure for $\pi$VAE involves learning a feature mapping $\Phi$ and a VAE to reconstruct function weights $\beta$.

Experimental Results

The authors evaluated $\pi$VAE across several diverse tasks, demonstrating its ability to capture complex function classes and perform efficient inference.

  • Spatial Interpolation: On the East Africa Land Surface Temperature data (~89,000 locations), $\pi$VAE achieved a test MSE of 0.38, compared to 2.47 for a full-rank GP and 4.36 for a low-rank GMRF.
  • GP Recovery and Uncertainty: The model successfully learned to mimic Gaussian Processes, capturing both the mean and the 95% credible intervals accurately while maintaining near-zero autocorrelation in MCMC samples.
  • Log-Gaussian Cox Process (LGCP): The $\pi$VAE was trained to output not just function values, but also properties like integrals, overcoming a major computational bottleneck in point process modeling.
$\pi$VAE learning a function from GP samples (a) and fitting to noisy data with uncertainty intervals (b).

Key Insights and Discussion

  • Portable Priors: By training the $\pi$VAE once on a specific function class, researchers create a "portable" prior that can be used for many different downstream inference tasks without re-calculating expensive kernels.
  • Latent Space Efficiency: Sampling in a 20-dimensional, uncorrelated latent space is orders of magnitude faster than sampling in the original high-dimensional function space. This allows "full" Bayesian inference to scale to datasets that were previously restricted to approximations.
  • Capturing Non-Stationarity: Because the feature mapping $\Phi(s)$ is a neural network, it can learn complex, non-stationary patterns that standard GP kernels often struggle to represent.

While the upfront training cost for $\pi$VAE can be high (taking days or weeks for millions of function draws), it represents a one-time cost for a universal prior in a specific domain. Future work aims to scale the framework to higher-dimensional input spaces and explore other process classes such as Dirichlet processes.

Summary updated

BibTeX
@misc{mishra2020pi,
  author = {Swapnil Mishra and Seth Flaxman and Samir Bhatt},
  title = {{$\textbackslash\{\}pi$VAE: Encoding stochastic process priors with variational autoencoders}},
  year = {2020},
  eprint = {2002.06873},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2002.06873},
}
Figure