SimpleGAN — Train GANs with 3 lines of code

Original article can be found here (source): Deep Learning on Medium


The domain of generative models in the context of deep learning has been rapidly growing in recent years, especially since the advent of adversarial networks. However, it has not always been easy to train these models even if you are an expert who is just trying to replicate the results on a custom dataset. Solution: SimpleGAN. SimpleGAN is a framework written using TensorFlow 2.0 that aims to facilitate the training of generative models by providing high-level APIs and at the same time great customizability to tweak your models and run experiments.


Installing SimpleGAN is a very easy process. There are two ways you can perform the installation.

  • Using pip package manager.
$ pip install simplegan
$ git clone
$ cd simplegan
$ python install


Now that you have installed the package (if not, you should 😁), let us have a look at two examples that will help you get started.

Let us take a look at how to train a convolutional autoencoder using the SimpleGAN framework


Let us now have look at an example where we will leverage adversarial training to translate images from one domain to another such as converting a segmentation map to an image with details. Check out this link.



For those of you who might be wondering “that is not 3 lines of code”, the above examples are just to showcase the available functionalities of the framework, technically you still need only the 3 lines of code shown below to train your model.

>>> gan = Pix2Pix()
>>> train_ds, test_ds = gan.load_data(use_maps = True)
>>>, test_ds, epochs = 100)

So yeah, this wasn’t a clickbait.

Important Links

  • Documentation — Check out the docs to get a better understanding of how of the methods provided by the framework
  • Example notebooks — The list of colab notebooks can help you get started and further understand the framework
  • Issues — Please file an issue at the Github page if you find any bugs with the framework


This framework was developed to ease the training of generative models with high-level abstractions and at the same time provides some options to customize the models. I believe “learning by doing” is the best way to understand new concepts and this framework can help people to get started.