Scaling GANs: ProGAN, SAGAN and BigGAN
How GANs reached 1024 × 1024 faces and all of ImageNet — ProGAN grows the networks, SAGAN adds self-attention and stabilizers, and BigGAN scales the recipe and trades variety for fidelity with the truncation trick.
Three ways to break
The topic Wasserstein GANs and Lipschitz constraints gave the adversary a gradient that does not die: a critic held Lipschitz by a gradient penalty or by spectral normalization. Together with the DCGAN architecture from GANs as a two-player game, this recipe trains well on faces. Ask it for faces, or for all thousand classes of ImageNet, and it fails in three different ways.
Resolution. A large image carries many fine details by which a fake can be told apart. The discriminator wins too easily, and the generator's gradient suffers (Karras et al., 2018, Section 1). Large images also eat memory, which forces small minibatches.
Long-range structure. On ImageNet, convolutional GANs drew texture classes such as sky or ocean well. They failed on classes with consistent geometry: dogs with realistic fur and no clearly separated feet (Zhang et al., 2019).
Many classes. A thousand classes are a thousand groups of modes. The generator has to cover all of them without collapsing onto a few.
Between 2017 and 2019 three papers took these on. ProGAN grows both networks during training. SAGAN adds self-attention and a set of stabilizers. BigGAN scales the SAGAN recipe up and adds class conditioning everywhere.
Growing the networks
ProGAN's answer to resolution is a curriculum (Karras et al., 2018). Small images carry less information and have fewer modes, so start there and add detail later.
Both networks begin at . Each time the resolution doubles, a block of layers is added to the end of and its mirror image to the start of . All existing layers keep training. The networks first learn the large-scale layout of a face, then finer and finer detail. Most iterations run at low resolution, where they are cheap.
A new block starts with random weights. Switching it on at once would shock the trained layers, so ProGAN fades it in. Let be the generator's features at resolution , nearest-neighbour upsampling by , a convolution from features to colours, and the new convolutions. During the transition the output image is a blend of the old path and the new one:
Here rises linearly from to . At the network is the old one with its output upsampled. At the old is dropped. The discriminator mirrors this with average pooling and layers, and real images are downscaled and blended between the two resolutions in the same way, so that compares like with like.
So every resolution has two phases: a fade-in, then a stretch of ordinary training at the new size before the next doubling.
Three ProGAN devices
Growing alone is not enough. ProGAN adds three small devices, none of which brings learned parameters of its own.
Minibatch standard deviation. The topic GANs as a two-player game met minibatch discrimination: let the discriminator see batch statistics to catch a collapsed generator. ProGAN does it with a layer that has no parameters. Near the end of it computes the standard deviation of every feature at every position over the minibatch, averages these into one number, and appends it as an extra constant feature map. Real images with one feature give ; a collapsed batch gives .
Equalized learning rate. He initialization draws a weight of a layer with fan-in at the scale . ProGAN instead stores every weight at scale , , and multiplies it by that constant at every forward pass:
At initialization nothing changes. The difference shows in training. Adam divides each update by a running estimate of the gradient's size, so it moves every stored parameter by roughly the learning rate per step, whatever that parameter's scale. With ProGAN's rate and He-scaled stored weights, a convolution over channels (, scale ) changes by about of its scale per step, while a over channels changes times more slowly. Stored at scale , every layer moves by about per step: equal learning speed, hence the name.
Pixelwise feature normalization. Signal magnitudes tend to escalate as the two networks compete (Karras et al., 2018, Section 4.2). Instead of batch normalization, the generator rescales the vector of channels at each pixel after every convolution:
For this gives : the root mean square of the channels becomes . The layer does not mix examples.
ProGAN trained with the WGAN-GP loss and sampled from a moving average of the generator's weights. It produced the first convincing faces, on CelebA-HQ, a set of curated celebrity photos built for the purpose.
SAGAN: self-attention
Faces are aligned and all of one kind. ImageNet has many classes, objects anywhere in the frame, and structure that spans the whole image.
A convolution mixes each position with its immediate neighbours. A stack of such layers sees a window, its receptive field. An output starts to depend on an input positions away only after layers, and those layers must coordinate to carry the information. A small model may not represent that, and an optimizer may not find it. Self-attention connects every pair of positions in one layer.
SAGAN adds one self-attention block to both networks (Zhang et al., 2019). View the feature map entering the block as vectors , one per position. Three convolutions , , act on each position separately. For every pair of positions the block computes a score and, with a softmax over , an attention weight:
is how much position attends to position ; for each the weights sum to . In transformer terms, is the query of position , and , are the key and value of position . The output at is the weighted sum of the values, mapped back to channels by a fourth convolution and added to the input with a learned scalar :
starts at . The network first learns from local evidence, which is easier, and lets distant evidence in as grows. The learned attention maps follow object shapes and similar textures rather than fixed neighbourhoods.
The price is the attention map: weights per image, over a million on a feature map. So SAGAN places the block at one moderate resolution only.
How SAGAN trains
SAGAN also changes how the two networks are trained.
Spectral normalization in both networks. In the WGAN topic, spectral normalization kept the critic Lipschitz. SAGAN applies it to every layer of the generator too. There it is a stabilizer with no Lipschitz requirement behind it: after the division no layer can amplify its input, however large the stored weights grow.
Two learning rates. A regularized discriminator learns slowly, which is why WGAN takes five critic steps per generator step. SAGAN takes one step each and gives the discriminator a larger learning rate instead: for and for . This is the two time-scale update rule, TTUR (Heusel et al., 2017). One faster step is cheaper than five slow ones.
The hinge loss. outputs a real number, with no sigmoid, like the WGAN critic. It is asked to score real images at least and fakes at most :
Beyond its margin an example contributes nothing, and its gradient for is zero. With real scores and fake scores , only the second real image and the second fake are inside their margins. The generator's loss is the WGAN one. Compared with the WGAN critic, the hinge stops pushing scores apart once they clear the margin. A margin of means something only because spectral normalization fixes the scale of ; without it, the discriminator could clear any margin by multiplying its output.
BigGAN: scale and the class label
BigGAN (Brock, Donahue and Simonyan, 2019) starts from SAGAN: residual networks with one attention block, the hinge loss, spectral normalization in both networks, two learning rates. Then it scales. A batch of instead of improved the Inception Score, a sample-quality score that the course meets in the evaluation module, by ; larger batches likely cover more modes per step and give both networks better gradients. Layers wider helped further. Progressive growing turned out to be unnecessary, even at .
The label in the generator. A batch-norm layer standardizes each channel with batch statistics , , then applies a learned scale and shift. Conditional batch norm (de Vries et al., 2017) makes the scale and shift functions of a conditioning vector :
The label now changes the scale and shift of every channel of every layer, so it acts on the whole generator. BigGAN builds from one shared embedding of the class , projected linearly to each layer's gains and biases. It also splits into six chunks of : one feeds the first layer, and each of the other five joins in the of one residual block. The latent then reaches features at every scale directly.
The label in the discriminator. In GANs as a two-player game the optimal discriminator's logit was the log density ratio. For pairs , split each density as :
Model both class posteriors as softmax classifiers on a shared feature vector . The first term becomes a difference of class vectors times , plus terms in alone. Collect everything in alone into one scalar head , and call the difference of class vectors a learned embedding . The result is the projection discriminator (Miyato and Koyama, 2018):
It is an unconditional realism score plus an inner product that measures how well the image's features match the class.
The truncation trick
A GAN never backpropagates through its prior, so the latent distribution used for sampling need not be the one used for training. BigGAN trains with and samples with the truncation trick: every coordinate of whose magnitude exceeds a threshold is redrawn until it falls inside .
Smaller thresholds pull toward the centre of the prior and the samples toward the most typical outputs of . Single images look better, while the set as a whole becomes less varied. Fidelity is bought with variety; the evaluation module will give these two the names precision and recall.
How far does this move the input? One coordinate is kept with probability , where is the standard normal CDF. For the -dimensional :
| kept per coordinate | std after truncation | typical | left untouched | |
|---|---|---|---|---|
Even the mild changes almost every vector: with coordinates, one of them is nearly always beyond . Under the training prior, of codes have norms between and , so at the generator receives inputs it has practically never seen. Only a generator that behaves smoothly away from its training inputs can take that.
To make that smooth, BigGAN adds orthogonal regularization to its weights. For a weight matrix whose columns are the filters, the diagonal of holds the squared filter norms and the off-diagonal entries their dot products. The full penalty would also force every filter to unit norm, which BigGAN found too limiting. It keeps only the off-diagonal part:
where is the all-ones matrix. The penalty pushes filters apart without constraining their norms. Across the authors' runs, of models without it tolerated truncation, against with it.
Collapse at scale and what comes next
The large BigGAN settings train well and then fail suddenly: within a few hundred iterations, sample quality drops from its peak to its worst.
The authors traced it to the discriminator. Before a collapse, it classified over of ImageNet training images as real, but only – of held-out validation images — no better than chance. It was memorizing the training set rather than learning what images look like. A gradient penalty on prevented the collapse but cost much of the sample quality. Freezing before a collapse left stable, while freezing made collapse at once: stability lives in the interaction of the two. BigGAN accepts the collapse and keeps the checkpoint from just before it.
Against the DCGAN of GANs as a two-player game, much has changed. The networks grow during training or become residual networks with attention. Batch normalization leaves the discriminator. The loss is WGAN-GP or hinge, with spectral normalization. The class label enters every layer of the generator. What stayed the same is the latent: one vector whose directions mix attributes. Its chunks reach different blocks, but nothing ties a direction in to one attribute such as pose or hair colour.
The next extension, StyleGAN: a style-based generator, rebuilds the generator around that problem. It maps to an intermediate latent space and injects the result as a "style" at every resolution, reusing ProGAN's equalized learning rate and the truncation trick on the way.
And the main line? Every model here is still a GAN: sharp samples, no likelihood, as the topic Wasserstein GANs and Lipschitz constraints ended. The main line picks up exactly there with The change of variables: normalizing flows, generators with an exact likelihood.
Check your understanding
The same questions as in Pulse. Answers are shared between modes.
Answers are saved on the server and tied to this browser until you sign in.