J. Bernardi

Project · Generative · 2024 · solo

Discriminator rejection sampling for GANs

Four variants of discriminator rejection sampling on MNIST, from a naive rule to adaptive truncation, and the quality–diversity trade-off each makes.

Generated digits as they leave the sampler. Accepted samples are inked; rejected ones are struck through in red. The scores shown are illustrative.

Problem

GANs still produce artefacts and miss modes. Discriminator Rejection Sampling (Azadi et al., 2019) keeps each generated sample with a probability that depends on the discriminator’s score D(x). The question is how to set that probability so quality improves without diversity collapsing.

Method

A fully connected GAN on MNIST: a four-layer generator and a three-layer discriminator (a weaker discriminator turned out to be a better filter). I built four variants in turn: basic DRS with a global normaliser, a ratio-based rule recomputed per batch, DRS with soft truncation of the latent code, and an adaptive soft truncation that only touches samples the discriminator scores poorly.

Results

Soft truncation buys the best precision at the cost of the worst recall; the adaptive variant keeps most of that precision and reaches the highest recall of the four. A Metropolis–Hastings sampler is the natural next step.

Measurements

SettingValueNote
Basic DRS (global M)P 0.48–0.50 · R 0.21
Ratio-based DRS (per-batch M)P 0.51–0.52 · R 0.22
DRS + soft truncationP 0.55 · R 0.16
DRS + adaptive soft truncationP 0.53 · R 0.24best balance

Precision and recall of the generated distribution for each sampling variant (project report).

Stack

Python · PyTorch · torchvision · NumPy · scikit-learn

Small print

Keyboard & errata

g i
Go to the index
g w
Go to work
g p
Go to the field log
g a
Go to about
g o
Go to now
t
Paper / darkroom
[ ]
Previous / next project
?
This sheet
  1. Index For “models taken apart”, read “models that took me apart, a little, each time”.
  2. GANs Some rejected digits were, on reflection, perfectly good digits.
  3. Work The list shows every project but one. See the missing one →