Foundations to Frontier
Tests
H. Generative Models › H4 Generative Adversarial Networks

BigGAN: large-scale class-conditional GANs

BigGAN (Brock, Donahue and Simonyan, ICLR 2019) showed that GANs improve dramatically with scale. Training class-conditional GANs on ImageNet with batches of 2048 and wide networks raised the Inception Score at 128 × 128 from about 52 to 166 and cut the FID from about 18.7 to 7.4. Making that work needed a package of techniques. The discriminator is a projection discriminator with spectral normalisation in both networks. The generator uses class-conditional batch norm with shared embeddings and a hierarchical latent, with orthogonal regularisation and the hinge loss. The truncation trick trades variety for fidelity at sampling time. The paper also documented how large GANs eventually collapse. This page covers the architecture, the scaling results, the truncation trick and its precision–recall trade-off, and the collapse analysis. In the exercises you build truncated latents, orthogonal regularisation, projection logits and hinge losses. You then train a class-conditional GAN on four classes of 2D data. Truncating the latent at τ = 0.5 raised precision from 0.60 to 0.69 but cut recall from 0.81 to 0.20. Larger batches reduced over-dispersion (spread 1.40 to 1.08 of the data's), but FID-style scores did not improve consistently with batch size.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Bigger batches, sharper pictures

BigGAN asked a simple question: what happens if you make a GAN much bigger and feed it much larger batches? The answer was a big jump in image quality on ImageNet’s 1000 classes. It also brought a handy dial: if you only sample the latent noise from near its centre, you get cleaner, more typical images with less variety. This is the truncation trick. The demo shows how many latent draws get thrown away, and how much the latent’s spread shrinks, as you turn that dial.

GAN lab 2: applications and stability
Resampling every |z| above τ = 1 rejects 31.7% of draws; the truncated latent has standard deviation 0.540. BigGAN trades variety for fidelity by lowering τ.
Why engineers care

Class-conditional generators can make labelled synthetic data for rare classes, for example uncommon aircraft or ship types in aerial imagery. The truncation dial controls whether those samples are typical or diverse; training data usually needs diversity.

📝 Quick check (Level 0)
0/3 answered
  1. 1. BigGAN mainly scaled up…
  2. 2. The truncation trick samples the latent…
  3. 3. Lower truncation gives…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Baseline. SAGAN (Zhang et al. 2019): self-attention, spectral normalisation in G and D, hinge loss, TTUR (D lr 4 × 10⁻⁴, G lr 10⁻⁴).
  • Scaling. Batch 256 → 2048 improved the Inception Score by 46%; 50% wider layers gave another 21%. The cost was 128 to 512 TPU v3 cores for 1–2 days.
  • Conditioning. Class-conditional batch norm in G: per-class gains and biases, produced linearly from a shared class embedding (not separate tables). Projection discriminator (Miyato and Koyama 2018): D(x, y) = φ(x)ᵀv + φ(x)ᵀe_y.
  • Hierarchical latent (skip-z). z (120-dimensional at 128 × 128) is split into chunks; each chunk is concatenated to the class embedding and feeds one generator block’s batch norm.
  • Orthogonal regularisation. β‖WᵀW ⊙ (1 − I)‖²_F with β = 10⁻⁴ (only off-diagonal terms) makes G amenable to truncation: 60% of models were amenable with it, versus 16% without.
  • Truncation trick. Sample z ~ N(0, I) and resample entries beyond a threshold τ; lower τ moves along the curve from high variety to high fidelity, such as IS up and FID eventually up.
  • Results (ImageNet 128 × 128). IS 166.5 and FID 7.4. BigGAN-deep (deeper, with bottleneck blocks) improved further; 256 and 512 models followed.
  • Collapse. Large models trained until collapse; spectral norms of G’s first layer blow up just before. Constraining D more stabilises training but hurts quality, so the authors used early stopping.
📝 Quick check (Level 1)
0/3 answered
  1. 1. The projection discriminator adds…
  2. 2. Batch 256 → 2048 improved IS by about…
  3. 3. Orthogonal regularisation helps G be…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Conditional GANs at scale

Exercise 1.

  • Truncated-normal latents (resampling).
  • Orthogonal regularisation.
  • Projection discriminator logits.
  • Hinge losses.

Practice.

  • Use pretrained BigGANs (TF Hub, pytorch-pretrained-biggan) for class-conditional sampling, or StudioGAN / BigGAN-PyTorch for training recipes.
  • Report fidelity and variety: FID together with precision and recall at several truncation levels, not one cherry-picked τ.
  • Batch size: large batches help, but GAN-specific settings (spectral norm, D steps, learning rates) must be retuned when scaling.
  • Watch for collapse: log spectral norms of G layers and FID; keep checkpoints and stop early.
  • Synthetic training data: sample with little or no truncation, otherwise the data lacks the variety a classifier needs.
# pip install pytorch-pretrained-biggan
import torch
from pytorch_pretrained_biggan import BigGAN, one_hot_from_names, truncated_noise_sample
model = BigGAN.from_pretrained("biggan-deep-256").eval()
y = torch.tensor(one_hot_from_names(["airliner", "warplane"], batch_size=2))
for tau in (1.0, 0.4):
    z = torch.from_numpy(truncated_noise_sample(truncation=tau, batch_size=2))
    with torch.no_grad():
        imgs = model(z, y, tau)          # lower tau: cleaner, less varied images
🐍 Exercise 1: BigGAN building blocks
Sample truncated latents, compute orthogonal regularisation, projection-discriminator logits and hinge losses.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Report FID with…
  2. 2. Log during training…
  3. 3. For synthetic training data use…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Why the projection discriminator. If the class-conditional log density ratio log q(y|x)/p(y|x) is modelled as log-linear in φ(x), the optimal conditional discriminator has the form ψ(φ(x)) + e_yᵀφ(x). Projection builds this structure in, rather than concatenating y to the input.

Truncation as a precision–recall dial. Resampling |z_i| > τ shrinks the latent’s spread: its standard deviation is √(1 − 2τφ(τ)/(2Φ(τ) − 1)), which is 0.54 at τ = 1 and 0.28 at τ = 0.5. G maps the high-density centre of z to its best-trained, most typical outputs, so precision rises; outputs that needed the tails disappear, so recall falls.

Why large batches help. Larger batches give lower-variance gradients for both players. In a game, gradient noise can push the dynamics off course rather than average out. Large batches also cover more classes per step, which matters with 1000 classes.

Hinge loss. D minimises E[max(0, 1 − D(x))] + E[max(0, 1 + D(G(z)))]; G minimises −E[D(G(z))]. Samples already beyond the margin contribute no gradient to D.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Truncation at τ = 1 shrinks each latent's std to about…
  2. 2. Projection D matches the optimal form when the density ratio is…
  3. 3. In the hinge loss, samples beyond the margin give D…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Do larger batches and truncation behave as BigGAN reported on a tiny class-conditional GAN?

History.

  • T. Miyato and M. Koyama, “cGANs with projection discriminator” (2018); H. Zhang et al., SAGAN (2019).
  • A. Brock, J. Donahue and K. Simonyan, “Large scale GAN training for high fidelity natural image synthesis” (ICLR 2019).
  • T. Kynkäänniemi et al., “Improved precision and recall metric for assessing generative models” (2019).

Exercise 2. A tiny class-conditional GAN.

  • Data: 4 classes in 2D, each an elongated Gaussian (sd 0.3 along the circle and 0.1 across it) at angle 2πc/4 on a circle of radius 2.
  • Models: G([z (4-dimensional), one-hot class]) → 2D with layers 32-32; projection D with 32-dimensional features; non-saturating loss, Adam (β1 = 0.5), 300 steps.
  • Batch sizes: 16, 64 and 256.
  • Metrics per class (averaged): 2D Fréchet distance (FID’s formula), class accuracy (nearest class centre), spread (sample std relative to the data’s), improved precision and recall (3-nearest-neighbour balls).
  • Truncation: for the batch-256 model, resample |z_i| > τ with τ = 1 and 0.5.
seed 0 FD spread precision recall
batch 16 0.254 1.404 0.53 0.775
batch 64 0.192 1.219 0.533 0.785
batch 256 0.186 1.083 0.597 0.812
batch 256, τ 1 0.166 0.752 0.64 0.357
batch 256, τ 0.5 0.16 0.477 0.687 0.198
  • Truncation behaved exactly as in BigGAN on every seed: precision rose and recall fell (seeds 1 and 2: precision 0.51 → 0.765 and 0.512 → 0.903; recall 0.672 → 0.358 and 0.683 → 0.365).
  • Batch size helped only partly: batch 256 was always less over-dispersed than batch 16 (spread 1.083, 1.458, 1.478 against 1.404, 1.505, 1.671). But FD was not monotone: on seed 1, batch 16 had the best FD (0.143). At equal step counts on a 2D toy, the BigGAN batch effect is weak. Honest null.
  • Class accuracy was 0.995–1.0 everywhere: the projection discriminator enforced the class easily.
  • FD barely moved under truncation (0.186 → 0.16), because means dominate it in 2D. Precision and recall show the trade-off much more clearly than a single FID-like number.
  • Caveat: no conditional batch norm, spectral norm or orthogonal regularisation in the toy, and only 300 steps.
🐍 Exercise 2 (research): do larger batches and truncation behave as BigGAN reported on a tiny class-conditional GAN?
Train a class-conditional GAN with a projection discriminator at batch sizes 16, 64 and 256; measure Fréchet distance, spread, precision and recall, and apply the truncation trick.

Class-conditional GANs in AI, robotics and aerospace

  • Rare-class augmentation: conditional GANs generate examples of under-represented classes (defects, rare vehicles). Check with a classifier trained only on real data, and keep truncation off.
  • Simulation-to-real: class-conditional generators make object appearance variations for detector training in robotics.
  • Today: class-conditional diffusion models (DiT, 2023) and autoregressive models exceed BigGAN’s FID. GANs survive as fast one-step generators and as discriminators in distillation methods (adversarial diffusion distillation).

References

  1. A. Brock, J. Donahue and K. Simonyan (2019). “Large scale GAN training for high fidelity natural image synthesis.” ICLR.
  2. T. Miyato and M. Koyama (2018). “cGANs with projection discriminator.” ICLR.
  3. H. Zhang, I. Goodfellow, D. Metaxas and A. Odena (2019). “Self-attention generative adversarial networks.” ICML.
  4. T. Kynkäänniemi et al. (2019). “Improved precision and recall metric for assessing generative models.” NeurIPS.