Coder Social home page Coder Social logo

discgen's Introduction

Discriminative Regularization for Generative Models

Samples banner

Code for the Discriminative Regularization for Generative Models paper.

Requirements

  • Blocks, development version
  • Fuel, development version

Downloading and converting the datasets

Set up your ~/.fuelrc file:

$ echo "data_path: \"<MY_DATA_PATH>\"" > ~/.fuelrc

Go to <MY_DATA_PATH>:

$ cd <MY_DATA_PATH>

Download the SVHN format 2 dataset:

$ fuel-download svhn 2
$ fuel-convert svhn 2
$ fuel-download svhn 2 --clear

Download the CIFAR-10 dataset:

$ fuel-download cifar10
$ fuel-convert cifar10
$ fuel-download cifar10 --clear

Download the CelebA dataset:

$ fuel-download celeba
$ fuel-convert celeba 64
$ fuel-download celeba --clear

Training the models

Make sure you're in the repo's root directory.

Download VGG19

Required for the SVHN and CIFAR10 models.

python scripts/download_vgg19

SVHN

Make sure you downloaded VGG19.

The SVHN experiment code will be published very soon.

CIFAR-10

Make sure you downloaded VGG19.

The CIFAR-10 experiment code will be published very soon.

CelebA

Train the CelebA classifier:

$ THEANORC=theanorc python experiments/train_celeba_classifier.py

Train a VAE without discriminative regularization:

$ THEANORC=theanorc python experiments/train_celeba_vae.py

Train a VAE with discriminative regularization:

$ THEANORC=theanorc python experiments/train_celeba_vae.py --regularize

Fine-tune the trained model:

$ THEANORC=theanorc scripts/adjust_population_statistics [trained_model.zip] [save_path.zip]

e.g.

$ THEANORC=theanorc scripts/adjust_population_statistics \
  celeba_vae_regularization.zip celeba_vae_regularization_adjusted.zip

Note: If you run out of memory in training, a good workaround is to reduce the training_batch_size and monitoring_batch_size.

Evaluating the models

Samples

$ THEANORC=theanorc scripts/sample [trained_model.zip]

e.g.

$ THEANORC=theanorc scripts/sample celeba_vae_regularization_adjusted.zip

CelebA samples

Reconstructions

$ THEANORC=theanorc scripts/reconstruct [which_dataset] [trained_model.zip]

e.g.

$ THEANORC=theanorc scripts/reconstruct celeba celeba_vae_regularization_adjusted.zip

CelebA reconstructions

Interpolations

$ THEANORC=theanorc scripts/interpolate [which_dataset] [trained_model.zip]

e.g.

$ THEANORC=theanorc scripts/interpolate celeba celeba_vae_regularization_adjusted.zip

CelebA interpolations

Note: All evaluation scripts use ipython. But this behavior can be overridden by explicitly using python on the command line along with a save path. For example:

THEANORC=theanorc python scripts/sample --save-path sample_no_reg.png celeba_vae_no_regularization.zip

NLL approximation

$ THEANORC=theanorc scripts/compute_nll_approximation [which_dataset] [trained_model.zip]

Note: this takes a long time.

discgen's People

Contributors

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