Dive into Deep Learning · §16.5
Adversarial image generation
the 2015 recipe · a modern minimal backbone · the loss A/B · measuring sample quality · limited data
DCGAN (Radford et al., 2015) made the classic loss train on images through architectural commitments:
Together, these choices control activation and optimizer statistics as the two networks change. The objective remains the non-saturating log loss of :numref:sec_basic_gan.

The samples have plausible palettes and rough sprite-like silhouettes. The architecture made the classic loss practical on images, but normalization does not remove its mode-dropping minima or divergent dynamics.
R3GAN’s principles at sprite scale:
Latent injection: project z linearly to 4 \times 4, concatenate with the learned constant, fuse with a mix conv — a deliberate simplification of R3GAN’s basis layer (z-modulated learned 4 \times 4 feature maps).
Identical backbone, initialization, optimizer, augmentation, EMA, and budget (15,000 steps). Only the loss differs:
d2l.update_D / d2l.update_G — the non-saturating log loss of :numref:sec_basic_gan;d2l.rpgan_loss_D/G + d2l.r1_r2_penalty, \gamma = 10 — the loss of :numref:sec_gan_convergence.\gamma picked by sweeping powers of ten: 1–100 all stable here, 0.1 collapses. R3GAN tunes \gamma from 0.05 to 150 per dataset — no single value is portable.
The arms differ in the complete loss recipe: pairing and penalties change together. The toy experiment in :numref:sec_gan_convergence and the cited StackedMNIST ablation isolate the individual components.

subsec_gan_limited_data.
Fit Gaussians to real and generated features, report the W_2^2 closed form :numref:sec_gan_objectives deferred:
\mathrm{FID} = \|\mu_p - \mu_q\|^2 + \operatorname{tr}\big(\Sigma_p + \Sigma_q - 2(\Sigma_p^{1/2} \Sigma_q \Sigma_p^{1/2})^{1/2}\big)
run FD (CIFAR-CNN) MMD^2 (CIFAR-CNN) out-of-range
real vs. real 0.53 0.03 --
classic 104.05 26.99 0.000
RpGAN + R1 + R2 2.50 0.67 0.157
Unbiased MMD^2 estimator, polynomial kernel on learned features — the kernel choice :numref:sec_gan_objectives fixed, reopened. Our cells print FD / MMD^2 (CIFAR-CNN): the same formulas on chapter-trained features, not comparable to published FID/KID. Real-vs-real floor \approx 0 — unbiased, so in principle it can even print negative; both scores rank the penalized run far above the collapsed one, with the floor two orders of magnitude below the gap.

median distance to nearest training image: generated 1.99, held-out real 0.68
The generator-side check is calibrated with held-out real images. Generated samples lie farther from the training set than held-out sprites do, and even the closest pairs depict different creatures. This test finds no evidence of direct copying.
R3GAN’s real budgets (quoted):
| benchmark | compute |
|---|---|
| StackedMNIST | 7 h on 8 L40 |
| CIFAR-10 | 4 days on 8 L40 |
| FFHQ-256 | ~3 weeks on 8 A6000 |
| ImageNet (cond.) | ~1 day on 32 H100 |
At scale: \gamma per dataset (0.05–150), BF16 not FP16, EMA half-life in Mimg, tuned augmentation. Steering the sampler with a class or caption: :numref:sec_gan_conditional.
sec_gan_conditional), then where the adversarial loss survives beyond stand-alone GANs (:numref:sec_gan_beyond).