Skip to content

This is a simple variational autoencoder (VAE) implemented in torch for R

License

Notifications You must be signed in to change notification settings

schmons/torch_R_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Implementation of a simple Variational Autoencoder (VAE) in torch for R

This is to explore what can be done with torch for R. Currently, this repo contains several basic implementations of variational autoencoders. We have

  • vae_mlp: a basic variational autoencoder using MLP encoder and decoder.
  • vae_cnn: same but using a more sophisticated convolutional neural network.
  • s_vae_mlp: a (fully) supervised VAE regularized by a classifier on top the latent variables. This is not the "standard" supervised VAE but instead follows ideas of Joy et. al. (2021)1, equation (2). This isn't the best way to do (semi-)supervised variational inference. A better version would be CCVAE, also introduced by Joy et. al. (2021)1, Section 4.2. (I might come back to implement this when I find the time.)

Note: The focus here was to build a working prototype, so the performance of each one of them is likely far from optimal and can be improved.

Dependencies

This implementation is based on torch for R. In addition, to load the MNIST dataset the code uses the dslab package. Some code also requires the ggsci package for color palattes.

Usage

The R files can be run in an IDE of choice such as RStudio.

Latent dimensions

The variable latent_dim at the beginning denotes the dimension of the latent variables. If latent_dim=2 the code will plot the latent variables created color-coded by the associated labels. This is particularly interesting for the supervised VAE.

Footnotes

  1. Joy, T., Schmon, S., Torr, P., Siddharth, N., & Rainforth, T. (2021). Capturing Label Characteristics in VAEs. In International Conference on Learning Representations. 2

About

This is a simple variational autoencoder (VAE) implemented in torch for R

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages