probml / pyprobml

Python code for "Probabilistic Machine learning" book by Kevin Murphy
MIT License
6.47k stars 1.52k forks source link

reimplement convolutional (variational) autoencoders in flax for celeba #1000

Closed murphyk closed 2 years ago

murphyk commented 2 years ago

figs 21.3 and 21.4 in book 2 (shown below) compare the reconstructon and unconditional sampling abilities of a convolutional AE and VAE. However these figures were generated by https://github.com/probml/pyprobml/blob/master/notebooks/book2/20/vae_compare_results.ipynb which relies on this somewhat complex pytorch lightning library: https://github.com/probml/pyprobml/tree/master/vae.

Please reproduce this basic demo using code that is similar to https://github.com/probml/pyprobml/blob/master/notebooks/book1/20/ae_mnist_conv_jax.ipynb. To get the celeba data you will have to follow the instructions at https://github.com/probml/pyprobml/tree/master/vae#download-celeba-data. For simplicity it is probably best to make a single colab that does everything, assuning that training can be done in under 5 minutes (if not, we may need to pretrain the models and store the checkpoints).

Screen Shot 2022-07-12 at 2 48 13 PM Screen Shot 2022-07-12 at 2 48 18 PM
murphyk commented 2 years ago

It would also be helpful to make a separate notebook that compares AE and VAE on MNIST so we can reproduce figs 20.24 and 20.25 from book1 (see below). You can factor out common code and put it in https://github.com/probml/probml-utils/.

Currently the reconstruction accuracy of the AE looks bad, which makes me suspect there is something wrong. Also the current code relies on pytorch code in https://github.com/probml/probml-utils/blob/main/probml_utils/ae_mnist_conv.py and https://github.com/probml/probml-utils/blob/main/probml_utils/vae_conv_mnist.py, which I would like to deprecate.

Screen Shot 2022-07-12 at 2 59 45 PM
murphyk commented 2 years ago

Also book 2 fig 20.7 uses the pytorch celebaA VAE code to do interpolation in latent space.

Screen Shot 2022-07-12 at 3 35 22 PM
murphyk commented 2 years ago

Book 2 fig 20.8 will also need to be remade. Currently uses https://github.com/probml/pyprobml/blob/master/notebooks/book2/20/vae_celebA_lightning.ipynb which uses the same pytorch code.

Screen Shot 2022-07-12 at 3 36 47 PM
nalzok commented 2 years ago

It has been done