<p align="center"></p>
## PyTorch-GAN
Collection of PyTorch implementations of Generative Adversarial Network varieties presented in research papers. Model architectures will not always mirror the ones proposed in the papers, but I have chosen to focus on getting the core ideas covered instead of getting every layer configuration right. Contributions and suggestions of GANs to implement are very welcomed.
<b>See also:</b> [Keras-GAN](https://github.com/eriklindernoren/Keras-GAN)
## Table of Contents
* [Installation](#installation)
* [Implementations](#implementations)
+ [Auxiliary Classifier GAN](#auxiliary-classifier-gan)
+ [Adversarial Autoencoder](#adversarial-autoencoder)
+ [BEGAN](#began)
+ [BicycleGAN](#bicyclegan)
+ [Boundary-Seeking GAN](#boundary-seeking-gan)
+ [Cluster GAN](#cluster-gan)
+ [Conditional GAN](#conditional-gan)
+ [Context-Conditional GAN](#context-conditional-gan)
+ [Context Encoder](#context-encoder)
+ [Coupled GAN](#coupled-gan)
+ [CycleGAN](#cyclegan)
+ [Deep Convolutional GAN](#deep-convolutional-gan)
+ [DiscoGAN](#discogan)
+ [DRAGAN](#dragan)
+ [DualGAN](#dualgan)
+ [Energy-Based GAN](#energy-based-gan)
+ [Enhanced Super-Resolution GAN](#enhanced-super-resolution-gan)
+ [GAN](#gan)
+ [InfoGAN](#infogan)
+ [Least Squares GAN](#least-squares-gan)
+ [MUNIT](#munit)
+ [Pix2Pix](#pix2pix)
+ [PixelDA](#pixelda)
+ [Relativistic GAN](#relativistic-gan)
+ [Semi-Supervised GAN](#semi-supervised-gan)
+ [Softmax GAN](#softmax-gan)
+ [StarGAN](#stargan)
+ [Super-Resolution GAN](#super-resolution-gan)
+ [UNIT](#unit)
+ [Wasserstein GAN](#wasserstein-gan)
+ [Wasserstein GAN GP](#wasserstein-gan-gp)
+ [Wasserstein GAN DIV](#wasserstein-gan-div)
## Installation
$ git clone https://github.com/eriklindernoren/PyTorch-GAN
$ cd PyTorch-GAN/
$ sudo pip3 install -r requirements.txt
## Implementations
### Auxiliary Classifier GAN
_Auxiliary Classifier Generative Adversarial Network_
#### Authors
Augustus Odena, Christopher Olah, Jonathon Shlens
#### Abstract
Synthesizing high resolution photorealistic images has been a long-standing challenge in machine learning. In this paper we introduce new methods for the improved training of generative adversarial networks (GANs) for image synthesis. We construct a variant of GANs employing label conditioning that results in 128x128 resolution image samples exhibiting global coherence. We expand on previous work for image quality assessment to provide two new analyses for assessing the discriminability and diversity of samples from class-conditional image synthesis models. These analyses demonstrate that high resolution samples provide class information not present in low resolution samples. Across 1000 ImageNet classes, 128x128 samples are more than twice as discriminable as artificially resized 32x32 samples. In addition, 84.7% of the classes have samples exhibiting diversity comparable to real ImageNet data.
[[Paper]](https://arxiv.org/abs/1610.09585) [[Code]](implementations/acgan/acgan.py)
#### Run Example
```
$ cd implementations/acgan/
$ python3 acgan.py
```
<p align="center">
</p>
### Adversarial Autoencoder
_Adversarial Autoencoder_
#### Authors
Alireza Makhzani, Jonathon Shlens, Navdeep Jaitly, Ian Goodfellow, Brendan Frey
#### Abstract
n this paper, we propose the "adversarial autoencoder" (AAE), which is a probabilistic autoencoder that uses the recently proposed generative adversarial networks (GAN) to perform variational inference by matching the aggregated posterior of the hidden code vector of the autoencoder with an arbitrary prior distribution. Matching the aggregated posterior to the prior ensures that generating from any part of prior space results in meaningful samples. As a result, the decoder of the adversarial autoencoder learns a deep generative model that maps the imposed prior to the data distribution. We show how the adversarial autoencoder can be used in applications such as semi-supervised classification, disentangling style and content of images, unsupervised clustering, dimensionality reduction and data visualization. We performed experiments on MNIST, Street View House Numbers and Toronto Face datasets and show that adversarial autoencoders achieve competitive results in generative modeling and semi-supervised classification tasks.
[[Paper]](https://arxiv.org/abs/1511.05644) [[Code]](implementations/aae/aae.py)
#### Run Example
```
$ cd implementations/aae/
$ python3 aae.py
```
### BEGAN
_BEGAN: Boundary Equilibrium Generative Adversarial Networks_
#### Authors
David Berthelot, Thomas Schumm, Luke Metz
#### Abstract
We propose a new equilibrium enforcing method paired with a loss derived from the Wasserstein distance for training auto-encoder based Generative Adversarial Networks. This method balances the generator and discriminator during training. Additionally, it provides a new approximate convergence measure, fast and stable training and high visual quality. We also derive a way of controlling the trade-off between image diversity and visual quality. We focus on the image generation task, setting a new milestone in visual quality, even at higher resolutions. This is achieved while using a relatively simple model architecture and a standard training procedure.
[[Paper]](https://arxiv.org/abs/1703.10717) [[Code]](implementations/began/began.py)
#### Run Example
```
$ cd implementations/began/
$ python3 began.py
```
### BicycleGAN
_Toward Multimodal Image-to-Image Translation_
#### Authors
Jun-Yan Zhu, Richard Zhang, Deepak Pathak, Trevor Darrell, Alexei A. Efros, Oliver Wang, Eli Shechtman
#### Abstract
Many image-to-image translation problems are ambiguous, as a single input image may correspond to multiple possible outputs. In this work, we aim to model a \emph{distribution} of possible outputs in a conditional generative modeling setting. The ambiguity of the mapping is distilled in a low-dimensional latent vector, which can be randomly sampled at test time. A generator learns to map the given input, combined with this latent code, to the output. We explicitly encourage the connection between output and the latent code to be invertible. This helps prevent a many-to-one mapping from the latent code to the output during training, also known as the problem of mode collapse, and produces more diverse results. We explore several variants of this approach by employing different training objectives, network architectures, and methods of injecting the latent code. Our proposed method encourages bijective consistency between the latent encoding and output modes. We present a systematic comparison of our method and other variants on both perceptual realism and diversity.
[[Paper]](https://arxiv.org/abs/1711.11586) [[Code]](implementations/bicyclegan/bicyclegan.py)
<p align="center">
</p>
#### Run Example
```
$ cd data/
$ bash download_pix2pix_dataset.sh edges2shoes
$ cd ../implementations/bicyclegan/
$ python3 bicyclegan.py
```
<p align="center">
</p>
<p align="center">
Various style translations by varying the latent code.
</p>
### Boundary-Seeking GAN
_Boundary-Seeking Generative Adversarial Networks_
#### Authors
R Devon Hjelm, Athul Paul Jacob, Tong Che, Adam Trischler, Kyunghyun Cho, Yoshua Bengio
#### Abstract
Generative adversarial networks (GANs) are a learning framework that rely on training a discriminator to estimate a measure of difference between a target and generated distributions. GANs, as normally formulated, rely on the generated samples being completely differentiable w.r.t. the generative parameters, and thus do not work for discrete data. We introduce a method for training GANs wit