Implementation of "Semantically Decomposing the Latent Spaces of Generative Adversarial Networks"
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
generate.ipynb Added simple generation example Oct 31, 2017

SD-GAN Tensorflow

Implementation of Semantically Decomposing the Latent Spaces of Generative Adversarial Networks (arXiv, demo).

Semantically decomposed GANs (SD-GANs) learn a decomposed latent space separating identity from the other contingent aspects of observations. In our paper, we demonstrate that SD-GANs can disentangle factors of variation corresponding to identity from photographs of celebrity faces and shoes. SD-GANs are especially applicable for datasets with many labels but few observations of each. Example results from an SD-GAN model; each row shares an identity and each column shares contingent factors:

We are currently in the process of improving the code for SD-BEGAN in the began branch. This branch is usable but does not produce results on par with our paper yet. To reproduce the SD-BEGAN results from our paper, please use this code (zip file), a fork of BEGAN-tensorflow.


Download one or both of the compressed datasets to sdgan/data:

Run training:

  1. Navigate to: sdgan/data
  2. Extract a dataset: tar xvfz msceleb12k.tar.gz
  3. Navigate to: sdgan
  4. Run training: ./
  5. Navigate to: sdgan/train
  6. (Optional) Run grid visualization: ./
  7. Run tensorboard: tensorboard --logdir=.


  • tensorflow (>= 1.0)
  • numpy

Adding new datasets

To add new datasets, follow the naming convention in the prepackaged ones above. Dataset folder must have subdirectory called train. train must contain 64x64 png files formatted as <ID_NAME>_<OBS_NUMBER>_<?>.png. In our datasets, <?> is the original aspect ratio for the source image of the 64x64 thumbnail, though the attribute is unused in our code.


If you use this dataset in your research, cite via the following BibTeX:

  title={Semantically Decomposing the Latent Spaces of Generative Adversarial Networks},
  author={Donahue, Chris and Lipton, Zachary C and Balsubramani, Akshay and McAuley, Julian},

Reference code/datasets


Chris Donahue (website, gscholar, twitter)