No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Latest commit c3b49bf Nov 29, 2018
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 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

Metropolis-Hastings GANs

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

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

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.


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.


First clone the repo:

git clone

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
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 --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, 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 and are designed to have general routines. The other files are scripts specific to this project.


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

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

cd mhgan
python --input [RESULTS SUBDIR] --output [FIGURES]


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