No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Latest commit c3b49bf Nov 29, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
mhgan README simiplification Nov 17, 2018
LICENSE Initial push of OSS MHGAN code. Nov 17, 2018
NOTICE Initial push of OSS MHGAN code. Nov 17, 2018
README.md typo in README fix Nov 29, 2018
requirements.txt Initial push of OSS MHGAN code. Nov 17, 2018
requirements_plots.txt Initial push of OSS MHGAN code. Nov 17, 2018

README.md

Metropolis-Hastings GANs

This repository contains the source code supporting the paper Metropolis-Hastings Generative Adversarial Networks:

@article{Turner2018,
  title={Metropolis-Hastings Generative Adversarial Networks},
  author={Ryan Turner and Jane Hung and Yunus Saatci and Jason Yosinski},
  journal={arXiv preprint arXiv:1811.11357},
  year={2018}
}

For more on this project, see the Uber AI Labs Blog post.

Getting Started

These instructions will get you a copy of the project up and running on your local machine.

Prerequisites

This code has been tested on Python 2.7.9 and the exact version of the dependencies are pinned in requirements.pip. It has been tested on Mac and Ubuntu.

Installing

First clone the repo:

git clone git@github.com:uber-research/metropolis-hastings-gans.git

Inside your virtual environments folder [ENVS] make the environment:

cd [ENVS]
virtualenv mhgan
source [ENVS]/mhgan/bin/activate

Move back into the git repo and run

pip install -r requirements.txt

You may want to run pip install -U pip first if you have an old version of pip.

This package also depends on benchmark tools. So also checkout that repo and install the package:

git clone https://github.com/rdturnermtl/benchmark_tools.git
cd benchmark_tools
pip install -e .

The environment should now all be setup to run the experiments.

Running the experiments

The main experiment script in this project is based on the pytorch DCGAN example. As such, it has the same command line interface.

One must specify a cache directory [DATA TMP] for the data to be stored and an output directory [RESULTS] for experiment results:

cd mhgan
python demo_mhgan.py --dataset cifar10 --dataroot [DATA TMP] --outf [RESULTS] --cuda --manualSeed 123

If there is no GPU on the system, drop the --cuda flag.

The script creates a new subdirectory to store the results to avoid overwriting the results of previous experiments. For instance: [RESULTS]/tmpNbBkwr. The created subdirectory name can be found in stdout at the start of demo_mhgan.py, which we call [RESULTS SUBDIR].

From the dumps in the [RESULTS SUBDIR] directory, summary plots can be made from the scripts with the .py files starting with plot_.

The files mh.py and classification.py are designed to have general routines. The other files are scripts specific to this project.

Plots

For plotting one must install matplotlib into the virtual environment. From the root of the repo run:

pip install -r requirements_plots.txt

The following functions generate plots based on the csv files dumped by demo_mhgan.py:

plot_calibration.py
plot_incep_by_epoch.py
plot_score_distn.py

These are called in the following way by providing the relevant directories:

cd mhgan
python plot_score_distn.py --input [RESULTS SUBDIR] --output [FIGURES]

License

This project is licensed under the Apache 2 License - see the LICENSE and NOTICE files for details.