Doubly Stochastic Variational Inference
- Doubly Stochastic Variational Inference is an optimization framework that uses mini-batch subsampling and Monte Carlo sampling to approximate intractable latent expectations.
- It enables scalable Bayesian inference for nonconjugate and high-dimensional models, including deep generative models and Gaussian processes.
- Variance reduction techniques such as Rao–Blackwellization and amortized control variates improve the efficiency and precision of stochastic gradient estimates in DSVI.
Doubly stochastic variational inference (DSVI) is an optimization framework for variational inference in probabilistic models with intractable per-data-point latent expectations and massive datasets. DSVI uses two layers of stochastic approximation: (1) mini-batch subsampling of the dataset to estimate expectations over observations, and (2) Monte Carlo sampling from variational or model distributions to approximate otherwise intractable expectations. This approach enables scalable approximate Bayesian inference for nonconjugate and high-dimensional latent variable models, including deep generative models, Bayesian nonparametrics, and privacy-preserving inference with gradient perturbations.
1. Concept and Theoretical Motivation
In standard variational inference, one introduces a family of tractable densities to approximate an intractable posterior , optimizing the Evidence Lower Bound (ELBO): where . When both the dataset is large and the expectations over are not analytically tractable (e.g., in nonconjugate models), direct gradient computations become infeasible. DSVI replaces both expectations with two Monte Carlo estimators: (i) random mini-batch sampling of the data, (ii) sampling from . The resulting stochastic gradient estimator for has independent noise from both sources: where and are mini-batch elements.
This doubly stochastic approach produces unbiased (in expectation) but noisy gradient estimates—suitable for stochastic optimization and compatible with modern automatic differentiation frameworks (Titsias, 2015).
2. Algorithmic Formulation and Gradient Estimation
The DSVI paradigm is instantiated in various model architectures by combining mini-batch data subsampling with MC estimation. For instance, in deep latent variable models (e.g., variational autoencoders, deep Gaussian processes), the computational structure typically takes the form: where is an intractable expectation. At each iteration:
- A random batch of size is sampled from .
- For each , MC samples are drawn.
- The gradient estimator is formed as
and the parameter update is (Kim et al., 2024, Titsias, 2015).
The key properties of this estimator are:
- Unbiasedness: .
- Variance decomposes into MC noise and mini-batch subsampling noise (Boustati et al., 2020, Kim et al., 2024).
- Modern theory provides non-asymptotic convergence rates for DSVI under ER (expected residual) and BV (bounded variance) assumptions.
3. Variance Reduction Techniques
The convergence of DSVI critically depends on the variance of its stochastic gradients. Several mechanisms have been developed to reduce this variance:
- Rao–Blackwellization: For conditionally factorized variational families, local expectation gradients (LeGrad) analytically integrate out a single latent variable conditional on all others, yielding strictly lower or equal variance compared to naive MC (“score function”) estimators and even the reparameterization trick in some cases (Titsias, 2015). The LeGrad update leverages the law of iterated expectations:
Empirically, this achieves up to an order of magnitude variance reduction.
- Amortized Control Variates: Neural networks can be trained online to output data-dependent control variate weights , resulting in a variance-reduced gradient estimator per component. This can drive the normalized variance of the minibatch gradient down to $0.2$–$0.3$ of the original (Boustati et al., 2020).
- Batch Size versus MC Simulation: For a fixed computational budget , variance analysis indicates that increasing the data minibatch size is more effective than increasing the number of MC samples , especially when MC samples for different batch elements are correlated. Using is frequently sufficient (Kim et al., 2024).
- Random Reshuffling: Replacing independent mini-batch sampling with random reshuffling at each epoch reduces the impact of subsampling noise and yields improved asymptotic complexity (Kim et al., 2024).
4. Applications in Gaussian Process Models
DSVI is foundational for scalable variational inference in both Gaussian Process Latent Variable Models (GPLVMs) and deep Gaussian processes:
- Bayesian GPLVM: The DSVI procedure involves mini-batch subsampling to approximate the ELBO and MC sampling to compute kernel statistics , , for each latent . The overall algorithm scales as per step, where is batch size and is the number of inducing points. Empirically, batch sizes –$500$, single-sample MC draws, and induce strong performance on high-dimensional data with massive missingness and automatic relevance determination properties (Lalchand et al., 2022).
- Deep Gaussian Processes: DSVI enables efficient fitting by drawing both mini-batch data and reparameterized latent paths through multiple GP layers. The computational cost is per step, and the method enables inference on datasets with up to (Salimbeni et al., 2017). Deeper architectures (DGPs with 3–5 layers) consistently surpass shallow GP baselines across regression and classification benchmarks.
5. Differential Privacy via DSVI
Differentially private variational inference can be implemented by integrating gradient clipping and noise perturbation into the DSVI optimization loop. The per-example gradient contributions in each mini-batch are clipped to a maximum norm , summed, and additive Gaussian noise with variance proportional to is added. Privacy amplification by subsampling further reduces cumulative privacy costs per step. Empirically, this approach matches non-private accuracy to within a few percent on Bayesian logistic regression and achieves strong privacy guarantees without the inefficiencies of DP-SGLD or sampling-based methods (Jälkö et al., 2016).
6. Practical Recommendations and Convergence Results
Theoretical analysis and empirical studies yield the following recommendations:
- Maximize batch size within hardware constraints; set MC sample size (or as small as possible without incurring high MC variance).
- Use random reshuffling over the dataset each epoch when feasible.
- Select moderate gradient clipping thresholds for DP-DSVI; small induces bias, large increases noise.
- In non-private DSVI, diminishing or adaptive step size schedules (e.g., Adam) ensure convergence to stationary points of the ELBO under standard stochastic approximation conditions.
- Monitor both MC and mini-batch variance sources to optimize the gradient estimator trade-offs (Kim et al., 2024, Titsias, 2015, Lalchand et al., 2022).
7. Comparative Analysis with Related Algorithms
DSVI unifies and generalizes several previous stochastic inference tools:
- Score-function / REINFORCE: Handles arbitrary (discrete/continuous) but suffers from high variance; typically requires control variates.
- Reparameterization trick: Lower variance for reparameterizable continuous models; not directly applicable to discrete or non-location-scale families.
- LeGrad: As general as score-function, systematically achieves lower variance by exact local marginalization, and is trivially parallelizable. Does not require additional control variates and can be integrated as a drop-in replacement into autodiff toolkits (Titsias, 2015).
The table summarizes key distinctions among algorithms:
| Estimator | Model Family Support | Variance Control |
|---|---|---|
| Score-function (REINFORCE) | Discrete + continuous | High; needs control vars |
| Reparameterization | Reparameterizable continuous | Low; limited generality |
| Local Expectation Gradients (LeGrad) | Discrete + continuous | Systematically low |
Systematic variance reduction, compatibility with GPUs and large-scale autodiff environments, and applicability to nonconjugate, high-dimensional latent structures distinguish DSVI as the foundation for modern scalable Bayesian machine learning (Titsias, 2015, Lalchand et al., 2022, Salimbeni et al., 2017, Boustati et al., 2020, Kim et al., 2024, Jälkö et al., 2016).