Conditional Inference in Pre-trained Variational Autoencoders via Cross-coding

Ga Wu, Justin Domke, Scott SannerarXiv 2018

Introduction

Variational Autoencoders (VAEs) have emerged as powerful generative models, yet they face a significant hurdle in conditional inference—the task of predicting missing data (the "query") based on observed segments (the "evidence"). While Conditional VAEs (CVAEs) can handle specific, pre-defined masks, they lack the flexibility to handle arbitrary patterns of missing data without exhaustive retraining. The traditional alternative, Markov Chain Monte Carlo (MCMC) sampling, is often prohibitively slow and difficult to tune in high-dimensional latent spaces.

This paper introduces cross-coding, a "plug-and-play" variational inference method that enables fast, arbitrary conditional inference in pre-trained VAEs. By optimizing a small auxiliary network to approximate the latent distribution for a given observation, the authors achieve significant performance gains without altering the original model weights.

The Cross-coding Framework

The core innovation is the cross-coder ($XCoder_\psi$), an auxiliary network designed to map a simple noise distribution to the specific region of the latent space that explains the observed evidence. Unlike standard VAEs that use an encoder to find latent variables, cross-coding treats inference as a rapid optimization problem.

Overview of the Cross-coding framework, illustrating the input, optimization, and prediction phases using a pre-trained VAE decoder.

Key technical components include:

  • Fixed Decoder: The method keeps the pre-trained VAE decoder fixed, ensuring that the generative knowledge already learned is preserved.
  • Conditional ELBO (C-ELBO): The authors derive a new objective function that bounds the true conditional distribution. Optimizing this allows the cross-coder to focus entirely on the latent variables relevant to the evidence.
  • Architectural Flexibility: The framework supports various cross-coder types, including simple Gaussian Variational Inference (GVI) and more complex Normalizing Flows (NF) for capturing multimodal distributions.

Theoretical Foundation and Insights

A key theoretical contribution of the paper is the identification of a "fortuitous cancellation" in the KL-divergence. The authors demonstrate that the error in predicting query variables is mathematically controlled by the error in the latent space approximation. This justifies focusing the optimization process entirely on the latent variables, simplifying the computational task.

Furthermore, the paper critiques the reliance on Hamiltonian Monte Carlo (HMC) in high-dimensional spaces. While HMC is theoretically robust, it frequently fails to "mix" effectively in the complex landscapes of modern VAEs, leading to mode collapse or failure to match observed pixels. Cross-coding avoids these pitfalls by framing inference as optimization rather than sampling.

Experimental Evaluation

The researchers evaluated cross-coding on MNIST, Anime Faces, and CelebA datasets. The results highlight two primary advantages: speed and quality.

  • Efficiency: Cross-coding is orders of magnitude faster than traditional sampling. On MNIST, GVI optimization took approximately 0.36 seconds, compared to 34.92 seconds for HMC—a nearly 100x speedup.
  • Handling Multimodality: In scenarios with ambiguous evidence (e.g., seeing only part of a digit that could be a '3' or a '5'), the Normalizing Flow (NF) variant of the cross-coder successfully captured multiple possible outcomes.
Conditional inference results on MNIST using the Normalizing Flow (NF) cross-coder, demonstrating its ability to capture multimodal distributions.

In high-dimensional tasks like CelebA (100-D latent space), cross-coding generated diverse, high-quality images that remained faithful to the observed evidence, whereas HMC often failed to converge to a realistic solution.

Conclusion

Cross-coding provides a robust and efficient solution for conditional inference in pre-trained VAEs. By shifting the paradigm from slow MCMC sampling to fast variational optimization, it enables real-time applications of generative models for tasks like image inpainting and data completion. Future work may explore even more sophisticated cross-coder architectures to handle increasingly complex, real-world data distributions.

Summary updated

BibTeX
@misc{wu2018conditional,
  author = {Ga Wu and Justin Domke and Scott Sanner},
  title = {{Conditional Inference in Pre-trained Variational Autoencoders via Cross-coding}},
  year = {2018},
  eprint = {1805.07785},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1805.07785},
}
Figure