Coder Social home page Coder Social logo

torch_r_examples's Introduction

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

torch_r_examples's People

Contributors

schmons avatar

Stargazers

 avatar Jack Gisby avatar Erik Volz avatar Koen Hufkens avatar Wan Nor Arifin avatar Matt W. Loftis avatar Adam Howes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.