Abstract
Conditional sampling of variational autoencoders (VAEs) is needed in various applications, such as missing data imputation, but is computationally intractable. A principled choice for asymptotically exact conditional sampling is Metropolis-within-Gibbs (MWG). However, we observe that the tendency of VAEs to learn a structured latent space, a commonly desired property, can cause the MWG sampler to get “stuck” far from the target distribution. This paper mitigates the limitations of MWG: we systematically outline the pitfalls in the context of VAEs, propose two original methods that address these pitfalls, and demonstrate an improved performance of the proposed methods on a set of sampling tasks.
The Challenge of Conditional Sampling
Variational Autoencoders (VAEs) excel at mapping complex data to a lower-dimensional latent space. While generating new samples (ancestral sampling) is straightforward, conditional sampling—predicting missing data $x_{\text{mis}}$ given observed data $x_{\text{obs}}$—is computationally difficult.
The standard approach uses Markov Chain Monte Carlo (MCMC) methods like Metropolis-within-Gibbs (MWG). However, the authors identify a "structure trap": the better a VAE is at learning a structured latent space, the harder it is to sample from. They categorize these failures into three pitfalls:
- Poor Mixing: Near-deterministic relationships between latents and visibles cause MCMC chains to get trapped in local modes.
- Narrow Proposals: The encoder often becomes too narrow, failing to explore alternative data interpretations.
- Initialization Sensitivity: Samplers may never find the true distribution if started in a low-probability region.
Proposed Methods: AC-MWG and LAIR
To address these pitfalls, the paper introduces two novel algorithms designed to mimic ancestral sampling more effectively.
1. Adaptive Collapsed-Metropolis-within-Gibbs (AC-MWG)
AC-MWG improves standard MWG through two key mechanisms:
- Collapsing: By marginalizing out missing variables when calculating acceptance probabilities, the sampler avoids getting stuck in rigid latent-visible relationships.
- Mixture Proposals: It suggests new latent states using a mixture of the encoder distribution (for local exploitation) and the prior distribution (for global exploration), allowing the chain to "jump" across low-probability valleys.
2. Latent-Adaptive Importance Resampling (LAIR)
LAIR moves away from MCMC toward Importance Resampling. It maintains a set of particles in the latent space and iteratively updates a proposal distribution. A "replenishing" mechanism ensures a portion of proposals always comes from the prior, preventing particle collapse and ensuring the sampler can find distant modes without requiring a burn-in period.
Key Results and Insights
The methods were evaluated on synthetic 2D models, MNIST, and real-world tabular and image datasets (UCI, Omniglot).
As shown in the visualizations above, AC-MWG (yellow) successfully captures the multi-modal nature of the true distribution, whereas standard MWG (pink) remains trapped in a single, often incorrect, mode. In quantitative experiments, AC-MWG and LAIR significantly outperformed baselines like Pseudo-Gibbs in terms of Fréchet Inception Distance (FID) and Root Mean Square Error (RMSE) for data imputation.
Conclusion
This work demonstrates that the very structure that makes VAEs powerful also makes them difficult to sample from conditionally. By integrating the VAE's prior into the sampling proposal and utilizing collapsed probabilities, AC-MWG and LAIR provide more robust and accurate data imputations. While computational costs and the curse of dimensionality remain challenges for future work, these methods represent a significant step toward reliable conditional generation in deep generative models.
Summary updated