16 / 34 · GANs
Scaling GANs: progressive growing, self-attention and BigGAN
How progressive growth, attention and class conditioning change GAN training, and what small reproducible examples reveal about normalization, truncation and stability.
Generative adversarial networks · Wasserstein GANs and Lipschitz constraints · Batch normalization, gradients and convolutions · Self-attention
On this page 6
Two distant parts of a generated object can have plausible textures and still disagree about its shape. Increasing the number of pixels makes that disagreement more expensive to detect; it does not specify how the generator should coordinate them. Training also has to accommodate new feature scales and class information. These difficulties remain even after choosing the adversarial objective.
ProGAN: growing the networks#
Progressive GAN starts with a low-resolution generator and discriminator, then adds blocks for finer resolutions. Existing layers remain trainable. The changing architecture gives early updates a simpler spatial task, while later blocks can refine the shared representation (Karras, Aila, Laine and Lehtinen, §2). This changes the optimization path; it is not a theorem that coarse structure will be learned correctly.
Fade-in of new layers#
A new block should not replace the current image-producing path abruptly. Let an upsampled old output be , the new path be , and a scheduled mixing coefficient satisfy . Blend them at the same spatial resolution:
The discriminator likewise blends the old downsampled route with the new route; real images are transitioned consistently. In the original procedure, generator upsampling uses nearest neighbors and discriminator downsampling uses averaging.
For an explicit four-site signal, set , , and target . Half the mean squared error becomes
At , the derivatives for are . The new branch initially receives no gradient through this blend, and its influence increases with the schedule. This calculation explains a transition mechanism, not adversarial convergence.
Minibatch standard deviation#
A discriminator that processes each item separately lacks an immediate comparison of variation across a batch. ProGAN computes standard deviations across samples for features, averages them into a scalar and appends that scalar as a constant feature map (§3). An implementation must specify grouping, the variance denominator and numerical epsilon.
Consider four two-dimensional samples in each of two batches:
Using denominator four and epsilon zero, both coordinates have variance five in both batches. The appended statistic is therefore in either case. Their cross-coordinate covariances are and . A batch repeating instead has zero standard deviation. The statistic detects this collapse, but cannot certify the joint distribution or coverage of all modes. Batch composition matters.
Equalized learning rate#
ProGAN initializes stored weights at a common scale and applies a fixed layer-dependent scale at runtime (§4.1). Write an effective weight as , where is our multiplicative scaling convention; a He-style choice is the square root of the ratio of two to fan-in. Chain rule scales the gradient of the stored weight by the same .
At the first bias-corrected Adam step, with an effective-weight gradient , learning rate and epsilon , the updates are
For , , , the effective steps at and are and . With zero epsilon, the stored first-step magnitudes coincide, while the effective steps still scale with . Optimizer history, epsilon and weight decay prevent a universal claim that all layers learn at identical speeds.
Pixelwise feature normalization#
ProGAN also normalizes a generator’s feature vector across channels at each spatial site (§4.2). For channels and positive epsilon:
For and , we obtain with mean square . Positive epsilon makes the result smaller than unit mean square. No channel mean is subtracted, so this is not centering. It controls a feature magnitude without establishing the diversity or correctness of the generated images.
SAGAN: self-attention for long-range structure#
Why convolutions miss long-range structure#
A stack of local convolutions can eventually connect distant sites, but the connection passes through multiple intermediate representations. Self-attention lets a site select information directly from other sites. SAGAN inserts such a block into both networks (Zhang, Goodfellow, Metaxas and Odena, §3). The added connectivity is useful capacity; appropriate relations still have to be learned.
The self-attention block#
Flatten a feature map into positions, each with channels. For query position , use keys , query and values . In the paper’s displayed formulation, all three projections have channels, and returns the aggregate to channels:
The softmax is over source positions ; rows of sum to one. This original formula does not include the transformer’s inverse-square-root score factor. The dense attention matrix requires storage quadratic in the number of positions. Reducing channel width does not remove that spatial cost.
In a scalar diagnostic, supply scores and values , with an identity output projection. The weights are and the aggregate is . For residual input , target and squared loss divided by two:
At the zero initialization used by SAGAN, gradients into this attention branch carry a factor and vanish, while the gate itself can move. Later its sign and magnitude depend on optimization; there is no requirement that it increase monotonically.
One query and a residual gate
Weighted values
| i | βᵢ | hᵢ | βᵢhᵢ |
|---|---|---|---|
| 1 | 1/6 | -3 | −1/2 |
| 2 | 1/3 | 0 | 0 |
| 3 | 1/2 | 4 | 2 |
o = −1/2 + 0 + 2 = 3/2
Output at different γ
Spectral normalization in both networks and two learning rates#
Spectral normalization divides a weight matrix by its largest singular value (Miyato, Kataoka, Koyama and Yoshida, §2). For the isolated linear map , exact normalization gives , whose Euclidean operator norm is one. Dividing by an underestimated value of two instead leaves norm . Power iteration provides an estimate, so its accuracy is relevant.
Even exact normalization of that layer does not give a one-Lipschitz residual block: has norm two. A whole-network bound requires accounting for compositions, sums, nonlinearities and normalization operations. SAGAN applies spectral normalization to both generator and discriminator; it does not thereby make every operation nonexpansive.
Separate generator and discriminator learning rates are another part of its recipe. The TTUR convergence analysis (Heusel et al., §2) assumes suitable smoothness, controlled gradient noise, bounded iterates and stable limiting dynamics, together with diminishing step schedules on separated time scales. Choosing two arbitrary constant rates does not meet that theorem’s assumptions by itself.
The hinge loss#
SAGAN uses a real-valued discriminator score and hinge penalties. Expectations below are over real examples and independently generated examples, with drawn from the latent distribution and the class condition suppressed:
where . At a score away from a hinge kink, a real item above one and a fake item below minus one contribute zero discriminator gradient. Generator updates still seek a larger fake score through their separate objective.
With real scores and fake scores , averaging within each group gives and . The discriminator has active examples in both groups. These scores are neither calibrated realness probabilities nor certified Wasserstein distances.
BigGAN: the same recipe at scale#
BigGAN combines a class-conditional residual architecture, attention, spectral normalization and hinge training with larger capacity and batches (Brock, Donahue and Simonyan, §3). Shared class embeddings and direct latent inputs at multiple depths alter how conditions reach the generator. Scaling is a joint design and optimization decision: more resources cannot guarantee that a previously useful training regime remains stable.
Class conditioning: conditional batch norm and projection#
Conditional batch normalization transforms a standardized feature using scale and offset derived from a class embedding. BigGAN also feeds latent information into these transformations. This provides each block with a condition instead of relying entirely on a signal transmitted from the input.
A projection discriminator scores compatibility between image features and a class embedding :
Its density-ratio motivation comes from class-conditional log-linear distributions (Miyato and Koyama, §§2–3). An exact small example makes the limitation visible. Let both real and model image variables be uniform on . Under the real law, the probability of class A is at and at ; under the model law it is at either value. All joint probabilities are positive.
Set , , , and . Then
Both laws have the same image marginal. A class-blind discriminator misses their different image–class relationships. The log-ratio identity describes the optimal logistic score in this constructed case; a projection network trained with hinge loss need not output that log ratio.
A hierarchical latent#
The original BigGAN splits the latent vector into chunks: one drives the initial representation, while later chunks join the shared class embedding in block-specific conditioning. BigGAN-deep instead supplies the full latent vector at multiple blocks. Direct access shortens the route from a random coordinate to a later layer. It does not prove that chunks become independent controls for interpretable attributes.
The truncation trick#
At inference, BigGAN can resample each standard-normal coordinate until its absolute value is at most a chosen positive threshold . This is rejection sampling, distinct from clipping values to the boundary. With standard-normal density and distribution function :
The conditional mean remains zero by symmetry. Since , integration by parts gives
Dividing by the retained mass gives the variance. For six independent coordinates, the probability that the original whole draw needs no replacement is . When rejected coordinates are redrawn individually, the expected total number of scalar draws is .
| Threshold | Coordinate variance | Entire six-vector unchanged |
|---|---|---|
| 0.6 | 0.114341 | 0.008471 |
| 1.2 | 0.394635 | 0.208196 |
| 2.4 | 0.890715 | 0.905574 |
A more concentrated latent does not guarantee better outputs. Declare an output valid when it lies in . For the map , threshold makes every output valid. For , it makes none valid, whereas the untruncated normal has a positive probability of reaching the valid interval. These are stipulated scalar validity tests, not image-quality measurements.
Less latent spread does not guarantee a better output
Latent distribution
- Coordinate variance
- All 6 coordinates unchanged
Specified test: |output| ≤ 1
- G₀(z) = z
- G₂(z) = z + 2
BigGAN reports a useful empirical fidelity–variety trade-off for some trained models, alongside models with truncation artifacts (§3.1). Evaluate the generated distribution at each threshold; neither latent variance nor a successful example establishes a universal quality improvement.
Orthogonal regularization#
BigGAN’s modified penalty removes the diagonal of the weight Gram matrix. Omitting its chosen strength for clarity, define
This penalizes squared inner products between different columns. To check the gradient, call the columns . Then
Each pair appears twice, so differentiating with respect to column gives
These columns form . Without fixed column norms it is not exactly a penalty on cosine similarities. For rows , the modified penalty is , the full penalty is , and the gradient rows are .
A diagonal matrix with entries three and two has zero modified penalty while retaining operator norm three. The zero matrix also has zero penalty. Orthogonal directions alone therefore establish neither unit gain nor information preservation. The regularizer changes an optimization preference; it does not certify that truncation or adversarial training will succeed.
Where it breaks: collapse at scale#
BigGAN’s analysis tracks weight spectra and tests interventions on both networks (§4). Keeping selected singular values controlled was insufficient to prevent collapse in the tested settings. Strong discriminator regularization could improve stability while damaging sample metrics. A correlated spectral spike is a warning signal; changing it experimentally is necessary to investigate a causal explanation.
Monitor both players, generated samples, class coverage and an independent validation protocol. A discriminator’s real-data acceptance rate alone is not balanced real-versus-fake accuracy: the generated comparison set and decision threshold matter. Keep checkpoints before deterioration, and avoid repeatedly selecting hyperparameters on the final evaluation set.
What the scores hide#
Changing truncation changes the generated law even when the weights are fixed. Report that threshold, conditioning distribution, feature extractor, sample count and random-seed policy alongside FID or precision and recall. Scores from incompatible protocols need not be comparable.
Nearest-neighbor inspection can reveal suspicious similarities within the reference collection and chosen feature space. Its failure to find one cannot prove absence of memorization. Separately inspect rare classes, repeated structures and invalid compositions; a scalar score averages away distinctions that matter to a user.
What changed#
Progressive growth changes when spatial detail enters the optimization. Attention changes which locations can communicate directly. Conditional normalization and projection make the class accessible throughout the two networks. Spectral and orthogonal controls constrain selected weight properties, while truncation changes inference-time sampling. Their effects interact and need separate checks.
What you should remember#
A smooth architectural transition is not a convergence guarantee. A minibatch statistic cannot identify every distributional defect. Attention’s gate and normalization’s epsilon affect actual gradients and magnitudes. Projection provides class compatibility without automatic score calibration. Truncation reduces latent spread, with output effects determined by the generator.
Code#
The standard-library companion executes the newly specified finite cases, derivative checks and normal-integral calculations. It trains no network and downloads no assets. Saved outputs supply the table and figures. This short fragment reproduces the hinge calculation:
from fractions import Fraction as F
real = [F(2), F(0), F(-1)]
fake = [F(-2), F(-1, 2), F(1)]
d_loss = sum(max(0, 1 - s) for s in real) / 3
d_loss += sum(max(0, 1 + s) for s in fake) / 3
g_loss = -sum(fake) / 3
print("Discriminator:", d_loss)
print("Generator:", g_loss)
Discriminator: 11/6
Generator: 1/2
Next#
StyleGAN changes how latent information modulates the generator. The next question is how this organization affects controllable variation and the artifacts introduced by normalization and sampling.
Where to see the images#
The original ProGAN, SAGAN and BigGAN papers contain the authors’ image comparisons. Read them with their training and evaluation settings. The calculations here concern explicitly defined small arrays and distributions; they do not reproduce those image-generation experiments.
References#
- Tero Karras, Timo Aila, Samuli Laine, Jaakko Lehtinen. Progressive Growing of GANs for Improved Quality, Stability, and Variation. ICLR, 2018. §§2–4: growth, batch statistic and normalizations.
- Han Zhang, Ian Goodfellow, Dimitris Metaxas, Augustus Odena. Self-Attention Generative Adversarial Networks. ICML, 2019. §§3–4: attention, spectral normalization, rates and hinge losses.
- Andrew Brock, Jeff Donahue, Karen Simonyan. Large Scale GAN Training for High Fidelity Natural Image Synthesis. ICLR, 2019. §§3–4 and Appendix B: conditioning, truncation, regularization and instability.
- Takeru Miyato, Toshiki Kataoka, Masanori Koyama, Yuichi Yoshida. Spectral Normalization for Generative Adversarial Networks. ICLR, 2018. §§2.1–2.2: operator norm and normalization.
- Takeru Miyato, Masanori Koyama. cGANs with Projection Discriminator. ICLR, 2018. §§2–3: conditional density-ratio motivation.
- Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, Sepp Hochreiter. GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium. NeurIPS, 2017. §2, assumptions A1–A5 and Theorem 1: the convergence contract.