Generative adversarial network

Generative · pattern · Noise or seed, Class label → Image

A generator turns random noise into images while a discriminator learns to tell them from real ones.

Also called GAN, DCGAN, Conditional GAN, StyleGAN

Figure 1. The Generative adversarial network as a schematic: the parts it is built from and how data flows between them. Select a part to read about it.

What it does

A GAN trains two networks against each other. The generator maps a random vector (and, in a conditional GAN, a class label) through dense and upsampling layers to an image. The discriminator is a classifier that sees real and generated images and outputs the probability that its input is real. The generator improves by producing images the discriminator accepts; the discriminator improves by catching them. After training only the generator is kept: each new noise vector, or seed, gives a new image. StyleGAN-type generators add per-layer style inputs and an RGB output layer at each resolution.

Formula

x̂ = G(z, c), z ~ N(0, I)minG maxD E[log D(x)] + E[log(1 − D(G(z)))]

Shapes and parameters

Shapes
Noise [N, 100] → features [N, 128, 8, 8] → image [N, 3, 32, 32]; the discriminator maps an image to [N, 1].
Parameters
Mostly in the first dense layer and the upsampling convolutions. The example generator has 827,392 + 131,136 + 3,075 ≈ 0.96 million.
Used for
The CIFAR-10 conditional GAN and the NanoDreamer room generator in the catalog; image synthesis and data augmentation.

Figure 2. A real generative adversarial network in WeightSpace: Generate a tiny image, drawn from the file the app runs. Open a module to see the parts inside.

In WeightSpace

Generators in the catalog are edited at the biases of the final RGB layer, which shift the red, green and blue of every pixel. The seed and the class stay fixed, so the before and after images differ only in color balance.