Skip to content
BIASED

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 64×6464 \times 64 faces. Ask it for 1024×10241024 \times 1024 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 4×44 \times 4. Each time the resolution doubles, a block of layers is added to the end of GθG_\theta and its mirror image to the start of DψD_\psi. 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 hrh_r be the generator's features at resolution rr, up\mathrm{up} nearest-neighbour upsampling by 22, toRGB\mathrm{toRGB} a 1×11 \times 1 convolution from features to colours, and block2r\mathrm{block}_{2r} the new convolutions. During the transition the output image is a blend of the old path and the new one:

x2r=(1−α) up(toRGBr(hr))+α toRGB2r(block2r(up(hr))).x_{2r} = (1 - \alpha)\,\mathrm{up}\big(\mathrm{toRGB}_r(h_r)\big) + \alpha\,\mathrm{toRGB}_{2r}\big(\mathrm{block}_{2r}(\mathrm{up}(h_r))\big).

Here α\alpha rises linearly from 00 to 11. At α=0\alpha = 0 the network is the old one with its output upsampled. At α=1\alpha = 1 the old toRGBr\mathrm{toRGB}_r is dropped. The discriminator mirrors this with average pooling and 1×11 \times 1 fromRGB\mathrm{fromRGB} layers, and real images are downscaled and blended between the two resolutions in the same way, so that DψD_\psi 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 DψD_\psi 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 (1,−1,2,0)(1, -1, 2, 0) give 1.1181.118; a collapsed batch (1.0,1.1,0.9,1.0)(1.0, 1.1, 0.9, 1.0) gives 0.0710.071.

Equalized learning rate. He initialization draws a weight of a layer with fan-in ninn_{\text{in}} at the scale 2/nin\sqrt{2/n_{\text{in}}}. ProGAN instead stores every weight at scale 11, w∼N(0,1)w \sim \mathcal N(0, 1), and multiplies it by that constant at every forward pass:

w^=2/nin  w.\hat w = \sqrt{2 / n_{\text{in}}}\; w .

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 10−310^{-3} and He-scaled stored weights, a 3×33 \times 3 convolution over 512512 channels (nin=4608n_{\text{in}} = 4608, scale 0.02080.0208) changes by about 4.8%4.8\% of its scale per step, while a 1×11 \times 1 fromRGB\mathrm{fromRGB} over 33 channels changes 3939 times more slowly. Stored at scale 11, every layer moves by about 0.1%0.1\% 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 h∈RCh \in \mathbb R^C of channels at each pixel after every convolution:

h^=h1C∑c=1Chc2+10−8.\hat h = \frac{h}{\sqrt{\frac1C \sum_{c=1}^{C} h_c^2 + 10^{-8}}} .

For h=(3,4)h = (3, 4) this gives (0.849,1.131)(0.849, 1.131): the root mean square of the channels becomes 11. 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 1024×10241024 \times 1024 faces, on CelebA-HQ, a set of 30,00030{,}000 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 3×33 \times 3 convolution mixes each position with its immediate neighbours. A stack of LL such layers sees a (2L+1)×(2L+1)(2L + 1) \times (2L + 1) window, its receptive field. An output starts to depend on an input 1616 positions away only after 1616 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 N=HWN = HW vectors hi∈RCh_i \in \mathbb R^C, one per position. Three 1×11 \times 1 convolutions WkW_k, WqW_q, WvW_v act on each position separately. For every pair of positions the block computes a score and, with a softmax over ii, an attention weight:

sij=(Wkhi)⊤(Wqhj),βj,i=exp⁡(sij)∑m=1Nexp⁡(smj).s_{ij} = (W_k h_i)^\top (W_q h_j), \qquad \beta_{j,i} = \frac{\exp(s_{ij})}{\sum_{m=1}^{N} \exp(s_{mj})} .

βj,i\beta_{j,i} is how much position jj attends to position ii; for each jj the weights sum to 11. In transformer terms, WqhjW_q h_j is the query of position jj, and WkhiW_k h_i, WvhiW_v h_i are the key and value of position ii. The output at jj is the weighted sum of the values, mapped back to CC channels by a fourth 1×11 \times 1 convolution WoW_o and added to the input with a learned scalar γ\gamma:

oj=Wo∑i=1Nβj,i Wvhi,yj=γ oj+hj.o_j = W_o \sum_{i=1}^{N} \beta_{j,i}\, W_v h_i, \qquad y_j = \gamma\, o_j + h_j .

γ\gamma starts at 00. The network first learns from local evidence, which is easier, and lets distant evidence in as γ\gamma grows. The learned attention maps follow object shapes and similar textures rather than fixed neighbourhoods.

The price is the attention map: N2N^2 weights per image, over a million on a 32×3232 \times 32 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: 4⋅10−44 \cdot 10^{-4} for DψD_\psi and 10−410^{-4} for GθG_\theta. 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. DψD_\psi outputs a real number, with no sigmoid, like the WGAN critic. It is asked to score real images at least 11 and fakes at most −1-1:

LD=Ex∼P[max⁡(0, 1−Dψ(x))]+Ez[max⁡(0, 1+Dψ(Gθ(z)))],LG=−Ez[Dψ(Gθ(z))].\mathcal L_D = \mathbb E_{x \sim P}\big[\max(0,\ 1 - D_\psi(x))\big] + \mathbb E_{z}\big[\max(0,\ 1 + D_\psi(G_\theta(z)))\big], \qquad \mathcal L_G = -\mathbb E_{z}\big[D_\psi(G_\theta(z))\big].

Beyond its margin an example contributes nothing, and its gradient for DψD_\psi is zero. With real scores (1.5,0.4)(1.5, 0.4) and fake scores (−2,0.3)(-2, 0.3), 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 11 means something only because spectral normalization fixes the scale of DψD_\psi; 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 20482048 instead of 256256 improved the Inception Score, a sample-quality score that the course meets in the evaluation module, by 46%46\%; larger batches likely cover more modes per step and give both networks better gradients. Layers 50%50\% wider helped further. Progressive growing turned out to be unnecessary, even at 512×512512 \times 512.

The label in the generator. A batch-norm layer standardizes each channel kk with batch statistics μk\mu_k, σk2\sigma_k^2, 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 uu:

CBN(h;u)=(1+ak⊤u) h−μkσk2+10−5+bk⊤u.\mathrm{CBN}(h; u) = \big(1 + a_k^\top u\big)\,\frac{h - \mu_k}{\sqrt{\sigma_k^2 + 10^{-5}}} + b_k^\top u .

The label now changes the scale and shift of every channel of every layer, so it acts on the whole generator. BigGAN builds uu from one shared embedding e(c)e(c) of the class cc, projected linearly to each layer's gains and biases. It also splits z∈R120z \in \mathbb R^{120} into six chunks of 2020: one feeds the first layer, and each of the other five joins e(c)e(c) in the uu 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 (x,c)(x, c), split each density as p(x,c)=p(c∣x) p(x)p(x, c) = p(c \mid x)\,p(x):

ln⁡pdata(x,c)qθ(x,c)=ln⁡pdata(c∣x)qθ(c∣x)+ln⁡pdata(x)qθ(x).\ln\frac{p_{\text{data}}(x, c)}{q_\theta(x, c)} = \ln\frac{p_{\text{data}}(c \mid x)}{q_\theta(c \mid x)} + \ln\frac{p_{\text{data}}(x)}{q_\theta(x)} .

Model both class posteriors as softmax classifiers on a shared feature vector F(x)F(x). The first term becomes a difference of class vectors times F(x)F(x), plus terms in xx alone. Collect everything in xx alone into one scalar head rr, and call the difference of class vectors a learned embedding e(c)e(c). The result is the projection discriminator (Miyato and Koyama, 2018):

Dψ(x,c)=r(F(x))+e(c)⊤F(x).D_\psi(x, c) = r\big(F(x)\big) + e(c)^\top F(x) .

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 z∼N(0,I)z \sim \mathcal N(0, I) and samples with the truncation trick: every coordinate of zz whose magnitude exceeds a threshold τ\tau is redrawn until it falls inside [−τ,τ][-\tau, \tau].

Smaller thresholds pull zz toward the centre of the prior and the samples toward the most typical outputs of GθG_\theta. 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 2Φ(τ)−12\Phi(\tau) - 1, where Φ\Phi is the standard normal CDF. For the 120120-dimensional zz:

τ\tau kept per coordinate std after truncation typical ∥z∥\lVert z \rVert zz left untouched
∞\infty 11 11 10.9510.95 11
22 0.95450.9545 0.8800.880 9.649.64 0.00370.0037
11 0.68270.6827 0.5400.540 5.915.91 1.3⋅10−201.3 \cdot 10^{-20}

Even the mild τ=2\tau = 2 changes almost every vector: with 120120 coordinates, one of them is nearly always beyond 22. Under the training prior, 90%90\% of codes have norms between 9.789.78 and 12.1112.11, so at τ=1\tau = 1 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 GθG_\theta that smooth, BigGAN adds orthogonal regularization to its weights. For a weight matrix WW whose columns are the filters, the diagonal of W⊤WW^\top W holds the squared filter norms and the off-diagonal entries their dot products. The full penalty ∥W⊤W−I∥F2\lVert W^\top W - I \rVert_F^2 would also force every filter to unit norm, which BigGAN found too limiting. It keeps only the off-diagonal part:

R(W)=λ ∥W⊤W⊙(1−I)∥F2,λ=10−4,R(W) = \lambda\,\big\lVert W^\top W \odot (\mathbf 1 - I) \big\rVert_F^2, \qquad \lambda = 10^{-4},

where 1\mathbf 1 is the all-ones matrix. The penalty pushes filters apart without constraining their norms. Across the authors' runs, 16%16\% of models without it tolerated truncation, against 60%60\% 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 98%98\% of ImageNet training images as real, but only 5050–55%55\% 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 DψD_\psi prevented the collapse but cost much of the sample quality. Freezing GθG_\theta before a collapse left DψD_\psi stable, while freezing DψD_\psi made GθG_\theta 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 zz whose directions mix attributes. Its chunks reach different blocks, but nothing ties a direction in zz 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 zz 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.

Full notes

Answers are saved on the server and tied to this browser until you sign in.