Skip to content
/ BDMC Public

PyTorch implementation of Bidirectional Monte Carlo, Annealed Importance Sampling, and Hamiltonian Monte Carlo.

License

Notifications You must be signed in to change notification settings

lxuechen/BDMC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BDMC

PyTorch implementation of Bidirectional Monte Carlo.

Requirements

  • python3
  • numpy
  • pytorch>=0.4.1
  • tqdm

What is Bidirectional Monte Carlo (BDMC)?

BDMC is a method of accurately sandwiching the log marginal likelihood (ML). It is mainly used to evaluate the quality of log-ML estimators [1]. The method achieves this by obtaining a lower bound with the usual Annealed Importance Sampling (AIS) [2], and an upper bound with Reversed AIS from an exact posterior sample. Since the upper bound requires an exact sample from the posterior, the method is only strictly valid on simulated data. However, the results obtained on simulated data can help verify the performance of log-ML estimators. Conditioned upon the assumption that the real data does not differ too much from the simulated data, the evaluation of the log-ML estimator on simulated data could be informative of the performance on real data.

The given implementation performs evaluation on a variational autoencoder (VAE) trained on MNIST.

To run

There is a pretrained VAE model (on MNIST) in the checkpoints folder. Executing the command

python bdmc.py \
  --latent-dim 50 \
  --batch-size 512 \
  --n-batch 2 \
  --chain-length 10000 \
  --iwae-samples 10 \
  --ckpt-path ./checkpoints/model.pth

will start the forward and backwards chain of BDMC based on the model loaded from the pretrained checkpoint.

References

[1] Grosse, Roger B., Zoubin Ghahramani, and Ryan P. Adams. "Sandwiching the marginal likelihood using bidirectional Monte Carlo." arXiv preprint arXiv:1511.02543 (2015).

[2] Neal, Radford M. "Annealed importance sampling." Statistics and computing 11.2 (2001): 125-139.

[3] Neal, Radford M. "MCMC using Hamiltonian dynamics." Handbook of Markov Chain Monte Carlo 2.11 (2011).

About

PyTorch implementation of Bidirectional Monte Carlo, Annealed Importance Sampling, and Hamiltonian Monte Carlo.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages