Git Product home page Git Product logo

adversarial_autoencoder's Introduction

Adversarial autoencoders

Cover

This repository contains code to implement adversarial autoencoder using Tensorflow.

Medium posts:

  1. A Wizard's guide to Adversarial Autoencoders: Part 1. Autoencoders?

  2. A Wizard's guide to Adversarial Autoencoders: Part 2. Exploring the latent space with Adversarial Autoencoders.

  3. A Wizard's guide to Adversarial Autoencoders: Part 3. Disentanglement of style and content.

  4. A Wizard's guide to Adversarial Autoencoders: Part 4. Classify MNIST using 1000 labels.

Installing the dependencies

Install virtualenv and creating a new virtual environment:

pip install virtualenv
virtualenv -p /usr/bin/python3 aa

Install dependencies

pip3 install -r requirements.txt

Note:

  • I'd highly recommend using your GPU during training.
  • tf.nn.sigmoid_cross_entropy_with_logits has a targets parameter which has been changed to labels for tensorflow version > r0.12.

Dataset

The MNIST dataset will be downloaded automatically and will be made available in ./Data directory.

Training!

Autoencoder:

Architecture:

To train a basic autoencoder run:

    python3 autoencoder.py --train True
  • This trains an autoencoder and saves the trained model once every epoch in the ./Results/Autoencoder directory.

To load the trained model and generate images passing inputs to the decoder run:

    python3 autoencoder.py --train False

Adversarial Autoencoder:

Architecture:

Cover

Training:

    python3 adversarial_autoencoder.py --train True

Load model and explore the latent space:

    python3 adversarial_autoencoder.py --train False

Example of adversarial autoencoder output when the encoder is constrained to have a stddev of 5.

Cover

Matching prior and posterior distributions.

Adversarial_autoencoder Distribution of digits in the latent space.

Supervised Adversarial Autoencoder:

Architecture:

Cover

Training:

    python3 supervised_adversarial_autoencoder.py --train True

Load model and explore the latent space:

    python3 supervised_adversarial_autoencoder.py --train False

Example of disentanglement of style and content: Cover

Semi-Supervised Adversarial Autoencoder:

Architecture:

Cover

Training:

    python3 semi_supervised_adversarial_autoencoder.py --train True

Load model and explore the latent space:

    python3 semi_supervised_adversarial_autoencoder.py --train False

Classification accuracy for 1000 labeled images:

Cover

Cover

Note:

  • Each run generates a required tensorboard files under ./Results/<model>/<time_stamp_and_parameters>/Tensorboard directory.
  • Use tensorboard --logdir <tensorboard_dir> to look at loss variations and distributions of latent code.
  • Windows gives an error when : is used during folder naming (this is produced during the folder creation for each run).I would suggest you to remove the time stamp from folder_name variable in the form_results() function. Or, just dual boot linux!

Thank You

Please share this repo if you find it helpful.

adversarial_autoencoder's People

Contributors

naresh1318 avatar warvito avatar wkelongws avatar

Watchers

 avatar  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.