Assignment 5: GANs

Discussion: May 23rd
Deadline: May 22nd, 20:00

Like last time, you can focus more on the basic implementation details (the GAN training loop is a bit more complex than usual), or start with an existing codebase and explore the models.

Note: For this assignment and in general, you can upload more than one notebook if you find this better, e.g. to avoid overly long notebooks with a looong string of pretty much independent experiments.

Basic Setup

Implementing the basic GAN logic isn’t too difficult. You will likely want to use low-level training loops (i.e. GradientTape) because of the non-trivial control flow. There are many examples around the web that can help you get started (but note that many are outdated, e.g. using TF 1.x). For example, there is a DCGAN guide on the TF website. There is also an assignment05_starter notebook on Gitlab with some more tips.

This should be enough for a functional training procedure. Train some models and generate samples for evaluation. They will most likely be terrible.

Take note: Evaluating whether GAN training is progressing/”working” is difficult. The loss values are not very informative. You will want to take some samples and plot them every so often while training is progressing to get an impression of the current state. However, even this can be misleading: You might run into mode collapse problems early on, which you can take as evidence that training is not working, and stop the process early. However, it could actually happen that the mode collapse “magically” gets fixed over the course of a few training iterations, and diverse samples are produced. For this reason, consider always training for a large number of steps (larger than e.g. VAEs) and just see what happens.

Improving GAN Training

GANs are notoriously difficult to train. In the rest of this assignment, you are asked to try out various ways to improve the basic procedure. There are countless advanced GAN variants, but for now you may focus on “tricks” to make the original formulation more stable. Here are some leads:

Include as many of these methods as you want/need into your model and try to achieve some nice samples! We strongly advise to try to go beyond MNIST here, if only to appreciate how much more difficult training GAN gets for other datasets! For example, it should not be difficult to adapt the code for CIFAR10.

Optional: Advanced GAN Architectures

GANs have come a long way since their original inception in 2014, and discussing and/or implementing all significant improvements is not feasible. Below you can find some more leads for advanced architectures; if you have the time, you may implement some of these, experiment with the associated parameters and compare with your previous implementation. Some of these methods may be discussed in class in future sessions. In principle you can also mix and match these methods with each other or the improvements from part 1. Some of these mixes might work well, others not at all…