Skip to content
Lagrangian VAE
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Lagrangian VAE

TensorFlow implementation for the paper A Lagrangian Perspective of Latent Variable Generative Models, UAI 2018 Oral.

Shengjia Zhao, Jiaming Song and Stefano Ermon, Stanford Artificial Intelligence Laboratory


In this paper, we generalize the objective of latent variable generative models to two targets:

  • Primal Problem: "mutual information objectives", such as maximizing / minimizing mutual information between observations and latent variables.
  • Constraints: "consistency", which ensures that the model posterior is close to the amortized posterior.

Lagrangian VAE provides a practical way to find the best trade-off between "consistency constraints" and "mutual information objectives", as opposed of performing extensive hyperparameter tuning. We demonstrate an example over InfoVAE, a latent variable generative model objective that requires tuning the strengths of corresponding hyperparameters.

As demonstrated in the following figure, LagVAE manages to find a near Pareto-optimal curve for the trade-off between mutual informtation and consistency.


  • click
  • gputil
  • tqdm


  • methods/ InfoVAE implementation (does not optimize Lagrange multiplers)
  • methods/ LagVAE implementation (optimization of Lagrange multipliers)


Please set environment variables EXP_LOG_PATH and DATA_PREFIX for logging experiments and downloading data prior to running the examples.

  • InfoVAE: python examples/ --mi=1.0 --e1=1.0 --e2=1.0
  • LagVAE: python examples/ --mi=1.0 --e1=86.0 --e2=5.0

Note that we scale up MMD by 10000 in the implementation, so --e2=5.0 for LagVAE means MMD < 0.0005.

Feel free to play around with different VariationalEncoder, VariationalDecoder, optimizers, and datasets.


If you find the idea or code useful for your research, please consider citing our paper:

  title={The Information Autoencoding Family: A Lagrangian Perspective on Latent Variable Generative Models},
  author={Zhao, Shengjia and Song, Jiaming and Ermon, Stefano},
  journal={arXiv preprint arXiv:1806.06514},


utils/ is based on an implementation in OpenAI Baselines.


tsong [at] cs [dot] stanford [dot] edu

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.