Skip to content
AIAI Wranglers

9 Generative Adversarial Networks

Every generative model we have studied so far (mixture models, the EM algorithm, variational inference) works by defining an explicit probability density pΞΈ(𝒙) and maximising its likelihood. This chapter introduces a radically different idea: what if we could learn to generate realistic data without ever writing down a density?

The generative adversarial network (GAN) achieves this by pitting two neural networks against each other in a game. A generator tries to produce fake data that looks real; a discriminator tries to tell fakes from real data. Through this adversarial competition, the generator learns to produce samples that are indistinguishable from the training data.

Key Idea.

The GAN is an implicit generative model: it defines a sampling procedure 𝒛↦GΞΈ(𝒛) but never computes pΞΈ(𝒙) explicitly. This is both a strength (no intractable normalisation constant, no restrictive density assumptions) and a weakness (no likelihood for model comparison, harder to diagnose failure modes).

Historical Note.

Ian Goodfellow conceived the idea of GANs in June 2014 during a discussion with colleagues at a bar in MontrΓ©al [1]. The key insight, using a discriminator to provide a training signal for the generator, came from the realisation that the density ratio pdata(𝒙)/pg(𝒙) is all you need to measure how well the generator is doing, and a classifier naturally estimates this ratio. The paper was submitted, reviewed, and accepted at NeurIPS 2014 in a matter of months, a remarkable pace for what would become one of the most cited papers in machine learning. Within five years, GANs could generate photorealistic faces at 1024Γ—1024 resolution [2].

The GAN Framework

Definition 1 (Generator and Discriminator).

A GAN consists of two neural networks:

  1. The generator GΞΈ:ℝm⁑→ℝd⁑ maps a latent code π’›βˆΌpz(𝒛) (typically 𝒩(0,I⁑) or Uniform[0,1]m) to a synthetic data point 𝒙^=GΞΈ(𝒛). The distribution of 𝒙^ is called pg.

  2. The discriminator DΟ•:ℝd⁑→[0,1] takes a data point 𝒙 and outputs the probability that 𝒙 is real (from pdata) rather than fake (from pg).

The GAN architecture. The generator GΞΈ maps latent noise 𝒛 to fake data 𝒙^. The discriminator DΟ• receives both real data 𝒙 and fakes, and outputs a probability of being real. The dashed arrow shows the adversarial gradient that trains the generator through the discriminator.

The Minimax Objective

The generator and discriminator play a two-player minimax game:

Definition 2 (GAN Value Function).

The GAN value function is (V)V(GΞΈ,DΟ•)=π”Όπ’™βˆΌpdata[log⁑DΟ•(𝒙)]+π”Όπ’›βˆΌpz[log⁑(1βˆ’DΟ•(GΞΈ(𝒛)))]. The discriminator wants to maximise V (correctly classify real and fake); the generator wants to minimise V (fool the discriminator): (Minimax)minθ⁑maxϕ⁑V(GΞΈ,DΟ•).

Example 1 (Reading the Objective).

  • When DΟ•(𝒙)β‰ˆ1 for real 𝒙: log⁑DΟ•(𝒙)β‰ˆ0 (good for D).

  • When DΟ•(GΞΈ(𝒛))β‰ˆ0 (discriminator correctly rejects fakes): log⁑(1βˆ’DΟ•(GΞΈ(𝒛)))β‰ˆ0 (good for D, bad for G).

  • When DΟ•(GΞΈ(𝒛))β‰ˆ1 (discriminator fooled): log⁑(1βˆ’DΟ•(GΞΈ(𝒛)))β‰ˆβˆ’βˆž (bad for D, good for G, but G minimises, so this is large negative = good).

The objective perfectly balances the two players: what helps one hurts the other.

Remark 1 (Connection to Binary Cross-Entropy).

The value function is simply the negative binary cross-entropy of the discriminator, where real samples have label y=1 and fake samples have label y=0. Training the discriminator to maximise V is equivalent to training a binary classifier with cross-entropy loss.

Theoretical Analysis

The Optimal Discriminator

For a fixed generator, we can solve for the best possible discriminator in closed form.

Proposition 1 (Optimal Discriminator).

For a fixed generator G with induced distribution pg, the discriminator that maximises V(G,D) is (OPTD)DGβˆ—(𝒙)=pdata(𝒙)pdata(𝒙)+pg(𝒙).

Proof.

For fixed G, we can write V as an integral over 𝒙: V(G,D)=βˆ«π’™[pdata(𝒙)log⁑D(𝒙)+pg(𝒙)log⁑(1βˆ’D(𝒙))]d𝒙. We maximise the integrand pointwise. For any 𝒙, define a=pdata(𝒙) and b=pg(𝒙) and consider h(y)=alog⁑y+blog⁑(1βˆ’y) for y∈(0,1). Taking the derivative: hβ€²(y)=ayβˆ’b1βˆ’y=0⟹yβˆ—=aa+b. The second derivative hβ€²β€²(y)=βˆ’a/y2βˆ’b/(1βˆ’y)2<0 confirms this is a maximum. Substituting back gives .

Example 2 (Interpreting the Optimal Discriminator).

When pdata(𝒙)=pg(𝒙) (generator perfectly matches data), Dβˆ—(𝒙)=1/2 everywhere, so the discriminator can do no better than random guessing. When pg(𝒙)=0 at some 𝒙 where pdata(𝒙)>0 (generator misses a mode), Dβˆ—(𝒙)=1 there, and the discriminator is certain 𝒙 is real.

Insight.

The optimal discriminator is a density ratio estimator: DGβˆ—(𝒙)=pdata(𝒙)pdata(𝒙)+pg(𝒙)=Οƒ(log⁑pdata(𝒙)pg(𝒙)), where Οƒ is the sigmoid function. This connects GANs to the broader idea of density ratio estimation, which appears throughout statistical machine learning.

The GAN Objective Equals the Jensen–Shannon Divergence

Theorem 1 (GAN Objective and JSD).

Substituting the optimal discriminator DGβˆ— into the value function gives: (C)C(G)=defmaxD⁑V(G,D)=βˆ’log⁑4+2⋅𝖣JS⁑(pdataβ€–pg), where 𝖣JS⁑ is the Jensen–Shannon divergence (Definition def:js in Chapter ch:divergences).

Proof.

Substituting into V: C(G)=𝔼pdata[log⁑pdata(𝒙)pdata(𝒙)+pg(𝒙)]+𝔼pg[log⁑pg(𝒙)pdata(𝒙)+pg(𝒙)]. Let m=12(pdata+pg). Then: C(G)=𝔼pdata[log⁑pdata2m]+𝔼pg[log⁑pg2m]=βˆ’log⁑4+𝖣KL⁑(pdataβ€–m)+𝖣KL⁑(pgβ€–m)=βˆ’log⁑4+2𝖣JS⁑(pdataβ€–pg).

Theorem 2 (Global Optimum of the GAN Game).

The global minimum of C(G) is βˆ’log⁑4, achieved if and only if pg=pdata.

Proof.

Since 𝖣JS⁑(pdataβ€–pg)β‰₯0 with equality iff pdata=pg, we have C(G)β‰₯βˆ’log⁑4 with equality iff pg=pdata. At this equilibrium, Dβˆ—(𝒙)=1/2 for all 𝒙.

Remark 2 (Connection to Chapter ch:divergences).

The GAN game implicitly minimises the Jensen–Shannon divergence between pdata and pg, one of the divergence measures studied in Chapter ch:divergences. Recall that 𝖣JS⁑ is symmetric, bounded (0≀𝖣JS⁑≀log⁑2), and always defined (unlike the KL divergence, which can be infinite when supports don't match). However, as we saw in Chapter ch:divergences, when pdata and pg have disjoint supports, 𝖣JS⁑ saturates at log⁑2, a problem we will revisit when motivating the Wasserstein GAN in the next chapter.

The f-GAN Perspective

The original GAN implicitly minimises the JSD. A natural question is: can we minimise any f-divergence? The answer is yes, via the variational representation of f-divergences.

Variational Lower Bound on f-Divergences

Recall from Chapter ch:divergences that the f-divergence is 𝖣f⁑(pβ€–q)=∫q(𝒙)f(p(𝒙)q(𝒙))d𝒙, where f is convex with f(1)=0. The key tool is the Fenchel conjugate.

Definition 3 (Fenchel Conjugate).

The Fenchel conjugate of a convex function f is (Fenchel)fβˆ—(t)=supu∈dom(f)⁑{tuβˆ’f(u)}. Since f is closed and convex, the biconjugate satisfies fβˆ—βˆ—=f, so f(u)=supt⁑{tuβˆ’fβˆ—(t)}.

Proposition 2 (Variational Representation of f-Divergence).

For any f-divergence: (VAR)𝖣f⁑(pβ€–q)=supT:𝒳→ℝ⁑⁑[π”Όπ’™βˆΌp[T(𝒙)]βˆ’π”Όπ’™βˆΌq[fβˆ—(T(𝒙))]].

Proof.

Substituting f(u)=supt⁑{tuβˆ’fβˆ—(t)} into the definition of 𝖣f⁑: 𝖣f⁑(pβ€–q)=∫q(𝒙)supt⁑{tp(𝒙)q(𝒙)βˆ’fβˆ—(t)}d𝒙=∫supt⁑{tp(𝒙)βˆ’fβˆ—(t)q(𝒙)}d𝒙β‰₯supT⁑∫[T(𝒙)p(𝒙)βˆ’fβˆ—(T(𝒙))q(𝒙)]d𝒙, where the inequality (swapping sup⁑ and ∫) becomes an equality when T is allowed to vary freely over all measurable functions. This gives .

Insight.

Equation transforms a divergence computation (which requires knowing the density ratio p/q) into an optimisation problem (which only requires samples from p and q). This is the mathematical engine that powers all GAN-like methods: the function T is parameterised by a neural network (the β€œcritic” or discriminator), and the optimisation is performed via stochastic gradient ascent.

From f-Divergence to GAN Objectives

Different choices of f yield different GAN variants. Nowozin et al. [9] systematised this in the f-GAN framework:

Definition 4 (f-GAN Objective).

Given a generator GΞΈ with pushforward pg, the f-GAN training objective is (FGAN)minθ⁑supϕ⁑[π”Όπ’™βˆΌpdata[TΟ•(𝒙)]βˆ’π”Όπ’›βˆΌpz[fβˆ—(TΟ•(GΞΈ(𝒛)))]].

Divergencef(u)fβˆ—(t)GAN Name
KLulog⁑uetβˆ’1KL-GAN
Reverse KLβˆ’log⁑uβˆ’1βˆ’log⁑(βˆ’t)RKLGAN
Jensen–Shannonulog⁑uβˆ’(u+1)log⁑u+12βˆ’log⁑(2βˆ’et)Original GAN
Pearson Ο‡2(uβˆ’1)2t2/4+tΟ‡2-GAN
Squared Hellinger(uβˆ’1)2t/(1βˆ’t)Hellinger GAN
f-GAN variants: different convex functions f yield different divergences and GAN objectives.

Example 3 (Recovering the Original GAN).

For the Jensen–Shannon divergence, the activation function TΟ•(𝒙)=log⁑DΟ•(𝒙) (where DΟ•:𝒳→(0,1)) gives: fβˆ—(TΟ•(𝒙))=βˆ’log⁑(2βˆ’elog⁑DΟ•(𝒙))=βˆ’log⁑(2βˆ’DΟ•(𝒙)). Using βˆ’log⁑(2βˆ’DΟ•(𝒙))=βˆ’log⁑(1βˆ’DΟ•(𝒙))+const (after absorbing the constant into the optimisation) and including terms, we recover the original GAN objective .

Training GANs in Practice

The Training Algorithm

Algorithm 1 (GAN Training via Alternating SGD).

Input: Dataset π’Ÿ, batch size m, discriminator steps k, learning rates Ξ·D,Ξ·G.

for each training iteration:

  1. Discriminator update (repeat k times): itemize

  2. Sample {𝒙(1),…,𝒙(m)} from π’Ÿ and {𝒛(1),…,𝒛(m)} from pz.

  3. Update Ο• by ascending: βˆ‡Ο•1mβˆ‘i=1m[log⁑DΟ•(𝒙(i))+log⁑(1βˆ’DΟ•(GΞΈ(𝒛(i))))]. itemize

  4. Generator update (once): itemize

  5. Sample {𝒛(1),…,𝒛(m)} from pz.

  6. Update ΞΈ by descending: βˆ‡ΞΈ1mβˆ‘i=1mlog⁑(1βˆ’DΟ•(GΞΈ(𝒛(i)))). itemize

Remark 3 (Choosing k).

The hyperparameter k controls the discriminator-to-generator update ratio. Using k=1 (one discriminator step per generator step) is the most common choice and keeps training balanced. Using k too large risks overfitting the discriminator; using k too small means the discriminator provides poor gradient signal. Goodfellow et al. [1] used k=1 in their experiments.

The Non-Saturating Loss

Caution.

The minimax generator loss log⁑(1βˆ’D(G(𝒛))) suffers from vanishing gradients early in training. When the discriminator easily rejects fakes (D(G(𝒛))β‰ˆ0), we have log⁑(1βˆ’D(G(𝒛)))β‰ˆlog⁑1=0, so the gradient βˆ‡ΞΈlog⁑(1βˆ’D(G(𝒛))) is near zero. The generator receives almost no learning signal precisely when it needs it most.

The practical fix is the non-saturating (NS) loss:

Definition 5 (Non-Saturating Generator Loss).

Instead of minimising 𝔼[log⁑(1βˆ’D(G(𝒛)))], the generator maximises: (LOSS)β„’GNS=π”Όπ’›βˆΌpz[log⁑DΟ•(GΞΈ(𝒛))].

Example 4 (Why Non-Saturating Helps).

When D(G(𝒛))β‰ˆ0 (early training):

  • Saturating loss: log⁑(1βˆ’0)=0, flat, no gradient.

  • Non-saturating loss: log⁑(0)β†’βˆ’βˆž, strong gradient pushing G to increase D(G(𝒛)).

When D(G(𝒛))β‰ˆ0.5 (equilibrium), both losses provide similar gradients. The NS loss simply provides stronger signal when the generator is far from equilibrium.

Remark 4 (What Divergence Does the NS Loss Minimise?).

Under the optimal discriminator, the NS generator loss corresponds to minimising: 𝖣KL⁑(pgβ€–pdata)βˆ’2𝖣JS⁑(pdataβ€–pg)+const. The reverse KL term 𝖣KL⁑(pgβ€–pdata) is mode-seeking: it penalises the generator for placing mass where pdata is small, but does not penalise missing modes. This contributes to the mode collapse phenomenon (Section Mode Collapse and Failure Modes).

Practical Guidelines: The DCGAN Recipe

Radford et al. [3] identified a set of architectural guidelines that stabilise GAN training for images:

GuidelineRationale
Replace pooling with strided convolutionsLearnable downsampling
Use batch normalisation in G and DStabilises gradient flow
Remove fully connected layersAll-convolutional
ReLU in generator (except output: tanh)Avoids saturation
LeakyReLU in discriminatorGradient flow for negatives
Use Adam with Ξ·=0.0002, Ξ²1=0.5Tuned for stability
DCGAN architectural guidelines [3].

Remark 5 (Spectral Normalisation).

A later influential technique is spectral normalisation [4], which constrains the Lipschitz constant of the discriminator by normalising each weight matrix by its largest singular value. This provides a more principled form of regularisation than batch norm and is now widely used.

Mode Collapse and Failure Modes

Despite their impressive results, GANs suffer from several well-known failure modes.

Mode Collapse

Definition 6 (Mode Collapse).

Mode collapse occurs when the generator maps all (or most) latent codes to a small region of data space, producing only a few types of outputs rather than the full diversity of the data distribution.

Example 5 (Mode Collapse in 1D).

Consider pdata=12𝒩(βˆ’5,0.1)+12𝒩(5,0.1) (two well-separated modes). If the generator parameterisation is G(𝒛)=ΞΌ (a single learnable scalar, ignoring 𝒛), then pg=δμ, a point mass. The generator can match one mode (ΞΌβ‰ˆβˆ’5 or ΞΌβ‰ˆ5) but never both.

Even with a more expressive generator, mode collapse can occur dynamically: the generator β€œchases” the discriminator's weak points, cycling between modes without ever covering all of them.

Mode collapse: the data distribution pdata (blue) has two modes, but the generator pg (red dashed) concentrates all its mass on only one mode, completely missing the other.

Why GANs Are Hard to Train

Key Idea.

GAN training is a minimax (saddle-point) problem, not a minimisation problem. Standard gradient descent finds minima, but there is no guarantee it finds saddle points. This is the root cause of GAN training instability.

Example 6 (Failure of Simultaneous GD on a Bilinear Game).

Consider the simplest minimax game: minθ⁑maxϕ⁑θ⋅ϕ, with Nash equilibrium at (ΞΈβˆ—,Ο•βˆ—)=(0,0). Simultaneous gradient descent gives updates: ΞΈt+1=ΞΈtβˆ’Ξ·Ο•t,Ο•t+1=Ο•t+Ξ·ΞΈt. This is a rotation: (ΞΈt,Ο•t) orbits the origin with increasing radius, diverging from the equilibrium! The eigenvalues of the update matrix (1βˆ’Ξ·Ξ·1) have magnitude 1+Ξ·2>1, confirming divergence.

The main failure modes in practice are:

  1. Mode collapse (Section Mode Collapse): generator produces limited variety.

  2. Training oscillation: generator and discriminator losses oscillate without converging.

  3. Discriminator domination: D becomes too strong too early, providing no useful gradient to G.

  4. Generator collapse: G produces nonsensical outputs (noise, artefacts).

Remark 6 (Mitigation Strategies).

Numerous techniques have been proposed to stabilise GAN training:

  • Wasserstein distance instead of JSD (the next chapter).

  • Gradient penalty [5]: regularise the discriminator's gradient norm.

  • Spectral normalisation [4]: control the Lipschitz constant.

  • Progressive growing: start at low resolution and gradually increase.

  • Two-timescale updates: use different learning rates for G and D.

The Wasserstein GAN, discussed in the next chapter, addresses the most fundamental issue: the JSD's behaviour when supports are disjoint.

Evaluating GANs

Since GANs do not provide a tractable density pΞΈ(𝒙), we cannot evaluate them via log-likelihood. Several surrogate metrics have been developed.

Definition 7 (FrΓ©chet Inception Distance (FID)).

chet Inception Distance The FID [6] compares the statistics of real and generated images in the feature space of a pretrained Inception network. Let (𝝁r,𝚺r) and (𝝁g,𝚺g) be the means and covariances of Inception features for real and generated images. Then: (FID)FID=‖𝝁rβˆ’πgβ€–2+trace⁑(𝚺r+𝚺gβˆ’2(𝚺r𝚺g)1/2). Lower FID = better quality. FID =0 iff the feature distributions are identical.

Remark 7 (FID Is a Wasserstein Distance).

The FID is exactly the squared 2-Wasserstein distance W22 between two Gaussians fitted to the Inception features. This connects GAN evaluation to the optimal transport theory of Chapter ch:divergences.

Definition 8 (Inception Score (IS)).

The Inception Score [7] measures: (IS)IS=exp⁑(π”Όπ’™βˆΌpg[𝖣KL⁑(p(y|𝒙)β€–p(y))]), where p(y|𝒙) is the Inception classifier's label distribution. Higher IS = samples are individually distinctive (low entropy p(y|𝒙)) and collectively diverse (high entropy p(y)).

Caution.

Both FID and IS have significant limitations:

  • They depend on a pretrained Inception network (ImageNet features may not suit all domains).

  • IS does not compare to real data, only measures internal diversity.

  • Neither captures fine-grained artefacts that humans notice.

  • FID can be gamed by memorising training data.

Use multiple metrics and always include visual inspection when evaluating generative models.

Remark 8 (Precision and Recall for Generative Models).

KynkÀÀnniemi et al. proposed separating GAN quality into precision (are generated samples realistic?) and recall (does the generator cover all modes of the data?). A model with high precision but low recall exhibits mode collapse; a model with low precision but high recall produces diverse but poor-quality samples.

The GAN Landscape

Since the original 2014 paper, GANs have evolved rapidly:

Key milestones in GAN development. Each addressed a fundamental limitation of its predecessor: DCGAN introduced convolutional architectures, WGAN replaced JSD with Wasserstein distance, WGAN-GP improved gradient penalty, and StyleGAN achieved photorealistic generation.

Remark 9 (Conditional GANs).

All the above GANs generate images unconditionally. Conditional GANs [8] augment both G and D with a conditioning variable π’š (e.g. a class label): minθ⁑maxϕ⁑𝔼(𝒙,π’š)[log⁑DΟ•(𝒙,π’š)]+𝔼𝒛,π’š[log⁑(1βˆ’DΟ•(GΞΈ(𝒛,π’š),π’š))]. This enables controllable generation: β€œgenerate a cat”, β€œgenerate a house with this floor plan”, etc. Conditional GANs underpin pix2pix (image-to-image translation) and many other applications discussed in later chapters.

Chapter Summary

  1. A GAN consists of a generator GΞΈ and discriminator DΟ• playing a minimax game.

  2. The optimal discriminator is a density ratio estimator; substituting it into the objective reveals that GANs minimise the Jensen–Shannon divergence.

  3. The f-GAN framework generalises GANs to any f-divergence via the Fenchel conjugate trick.

  4. In practice, the non-saturating loss replaces the minimax generator loss to avoid vanishing gradients.

  5. GANs suffer from mode collapse, training oscillation, and convergence difficulties inherent to minimax optimisation.

  6. Evaluation relies on surrogate metrics (FID, IS) since GANs have no tractable likelihood.

  7. The JSD's saturation when supports are disjoint motivates the Wasserstein GAN (next chapter).

Exercises

Exercise 1 (Optimal Discriminator Derivation).

For the GAN objective with fixed G:

  1. (a)

    Show that the optimal discriminator is DGβˆ—(𝒙)=pdata(𝒙)/(pdata(𝒙)+pg(𝒙)).

  2. (b)

    Show that when pdata=pg, we have Dβˆ—(𝒙)=1/2 for all 𝒙. Interpret this.

  3. (c)

    What happens to Dβˆ—(𝒙) at a point 𝒙 where pg(𝒙)=0 but pdata(𝒙)>0?

Exercise 2 (GAN Objective and JSD).

After substituting DGβˆ— into the objective, show that C(G)=βˆ’log⁑4+2𝖣JS⁑(pdataβ€–pg), and conclude C(G)β‰₯βˆ’log⁑4 with equality iff pg=pdata.

Exercise 3 (Non-Saturating Loss Analysis).

  1. (a)

    Show that when D(G(𝒛))β‰ˆ0, the gradient of the saturating loss log⁑(1βˆ’D(G(𝒛))) is near zero.

  2. (b)

    Show that the NS loss βˆ’log⁑D(G(𝒛)) has strong gradients in the same regime.

  3. (c)

    Show that under the optimal discriminator, the NS generator loss corresponds to minimising 𝖣KL⁑(pgβ€–pdata)βˆ’2𝖣JS⁑(pdataβ€–pg)+const.

  4. (d)

    Explain why the reverse KL term can lead to mode collapse.

Exercise 4 (Mode Collapse Scenario).

Let pdata=12𝒩(βˆ’5,0.1)+12𝒩(5,0.1) and G(𝒛)=ΞΌ (constant).

  1. (a)

    Show the generator can never capture both modes.

  2. (b)

    Describe qualitatively how ΞΌ evolves during training.

  3. (c)

    Suggest a generator architecture that can capture both modes.

Exercise 5 (f-Divergence Variants).

  1. (a)

    Show that f(u)=ulog⁑u gives the KL divergence. Compute its Fenchel conjugate fβˆ—(t)=etβˆ’1.

  2. (b)

    Show that f(u)=βˆ’log⁑u gives the reverse KL. Compute fβˆ—.

  3. (c)

    For the Pearson Ο‡2 divergence (f(u)=(uβˆ’1)2), show that fβˆ—(t)=t2/4+t.

  4. (d)

    Write the resulting GAN training objective for each case.

Exercise 6 (GAN Training Dynamics).

  1. (a)

    Explain why k>1 discriminator steps per generator step can be beneficial. What happens if k is too large?

  2. (b)

    If D is optimal at every step, show G minimises 2𝖣JS⁑(pdataβ€–pg)βˆ’log⁑4.

  3. (c)

    For the bilinear game V(ΞΈ,Ο•)=ΞΈΟ•, show that simultaneous gradient descent diverges from the Nash equilibrium (0,0).

Exercise 7 (FID Computation).

Suppose Inception features for real images have 𝝁r=(1,0)𝖳, 𝚺r=I⁑, and for generated images 𝝁g=(2,1)𝖳, 𝚺g=2I⁑.

  1. (a)

    Compute ‖𝝁rβˆ’πgβ€–2.

  2. (b)

    Compute (𝚺r𝚺g)1/2 and the trace term in the FID formula.

  3. (c)

    What is the total FID?

  4. (d)

    How does FID change if we double all variances?

Exercise 8 (Density Ratio Interpretation).

  1. (a)

    Show that the optimal discriminator satisfies log⁑Dβˆ—(𝒙)1βˆ’Dβˆ—(𝒙)=log⁑pdata(𝒙)pg(𝒙).

  2. (b)

    Explain how this means training a discriminator is equivalent to estimating the log-density ratio.

  3. (c)

    If we had access to the exact density ratio, how could we compute the KL divergence 𝖣KL⁑(pdataβ€–pg) without knowing either density explicitly?

Exercise 9 (Comparing GAN and VAE).

  1. (a)

    List three advantages of GANs over VAEs.

  2. (b)

    List three advantages of VAEs over GANs.

  3. (c)

    A VAE generates blurry images; a GAN generates sharp but less diverse images. Explain this in terms of the divergences each model minimises (forward KL vs. reverse KL / JSD).

  4. (d)

    Can the two approaches be combined? Describe one hybrid model.

Exercise 10 (Conditional GAN Objective).

  1. (a)

    Write the minimax objective for a conditional GAN with class label y.

  2. (b)

    Derive the optimal conditional discriminator Dβˆ—(x,y).

  3. (c)

    Show that the conditional GAN minimises 𝖣JS⁑(pdata(𝒙|y)β€–pg(𝒙|y)) for each y.

Exercise 11 (JSD Saturation and WGAN Motivation).

Let p=𝒩(0,Ο΅2) and q=𝒩(ΞΌ,Ο΅2) for small Ο΅>0.

  1. (a)

    For what values of ΞΌ/Ο΅ are p and q β€œessentially disjoint” (overlap <0.01)?

  2. (b)

    Show that when p and q are disjoint, 𝖣JS⁑(pβ€–q)=log⁑2 regardless of the distance between them.

  3. (c)

    In contrast, show that the Wasserstein distance W1(p,q)=|ΞΌ| varies smoothly with ΞΌ.

  4. (d)

    Explain why this makes JSD unsuitable as a GAN training signal when pdata and pg live on low-dimensional manifolds.

Exercise 12 (Inception Score from Scratch).

A toy β€œInception classifier” has 3 classes and produces the following label distributions for 4 generated images:

ImageP(y=1|𝒙)P(y=2|𝒙)P(y=3|𝒙)
10.90.050.05
20.10.80.1
30.90.050.05
40.050.10.85

  1. (a)

    Compute the marginal p(y)=14βˆ‘ip(y|𝒙i).

  2. (b)

    Compute 𝖣KL⁑(p(y|𝒙i)β€–p(y)) for each image.

  3. (c)

    Compute the Inception Score.

  4. (d)

    What IS would you get if all images had the same label distribution (1/3,1/3,1/3)? Explain why.

References

  1. Generative Adversarial Networks

    Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, Yoshua Bengio

    Advances in Neural Information Processing Systems, vol. 27 Β· 2014

    BibTeX
    @inproceedings{goodfellow2014generative,
      title={Generative Adversarial Networks},
      author={Goodfellow, Ian and Pouget-Abadie, Jean and Mirza, Mehdi and Xu, Bing and Warde-Farley, David and Ozair, Sherjil and Courville, Aaron and Bengio, Yoshua},
      booktitle={Advances in Neural Information Processing Systems},
      volume={27},
      year={2014}
    }

    Conference paper

  2. A Style-Based Generator Architecture for Generative Adversarial Networks

    Tero Karras, Samuli Laine, Timo Aila

    Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4401-4410 Β· 2019

    BibTeX
    @inproceedings{karras2019style,
      title={A Style-Based Generator Architecture for Generative Adversarial Networks},
      author={Karras, Tero and Laine, Samuli and Aila, Timo},
      booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
      pages={4401--4410},
      year={2019}
    }

    Conference paper

  3. Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks

    Alec Radford, Luke Metz, Soumith Chintala

    International Conference on Learning Representations Β· 2016

    BibTeX
    @inproceedings{radford2015unsupervised,
      title={Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks},
      author={Radford, Alec and Metz, Luke and Chintala, Soumith},
      booktitle={International Conference on Learning Representations},
      year={2016}
    }

    Conference paper

  4. Spectral normalization for generative adversarial networks

    Takeru Miyato, Toshiki Kataoka, Masanori Koyama, Yuichi Yoshida

    Proceedings of the International Conference on Learning Representations Β· 2018

    BibTeX
    @inproceedings{miyato2018spectral,
      title={Spectral normalization for generative adversarial networks},
      author={Miyato, Takeru and Kataoka, Toshiki and Koyama, Masanori and Yoshida, Yuichi},
      booktitle={Proceedings of the International Conference on Learning Representations},
      year={2018},
      url={https://openreview.net/forum?id=B1QRgziT-}
    }

    Conference paper

  5. Improved training of Wasserstein GANs

    Ishaan Gulrajani, Faruk Ahmed, Martin Arjovsky, Vincent Dumoulin, Aaron C Courville

    Advances in neural information processing systems, pp. 5767-5777 Β· 2017

    BibTeX
    @inproceedings{gulrajani2017improved,
      title={Improved training of Wasserstein GANs},
      author={Gulrajani, Ishaan and Ahmed, Faruk and Arjovsky, Martin and Dumoulin, Vincent and Courville, Aaron C},
      booktitle={Advances in neural information processing systems},
      pages={5767--5777},
      year={2017}
    }

    Conference paper

  6. Gans trained by a two time-scale update rule converge to a local nash equilibrium

    Martin Heusel, Hubertus Ramsauer, Thomas Unterthiner, Bernhard Nessler, Sepp Hochreiter

    Advances in Neural Information Processing Systems, pp. 6626-6637 Β· 2017

    BibTeX
    @inproceedings{heusel2017gans,
      title={Gans trained by a two time-scale update rule converge to a local nash equilibrium},
      author={Heusel, Martin and Ramsauer, Hubertus and Unterthiner, Thomas and Nessler, Bernhard and Hochreiter, Sepp},
      booktitle={Advances in Neural Information Processing Systems},
      pages={6626--6637},
      year={2017}
    }

    Conference paper

  7. Improved techniques for training GANs

    Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, Xi Chen

    Advances in Neural Information Processing Systems, pp. 2234-2242 Β· 2016

    BibTeX
    @inproceedings{salimans2016improved,
    title={Improved techniques for training GANs},
    author={Salimans, Tim and Goodfellow, Ian and Zaremba, Wojciech and Cheung, Vicki and Radford, Alec and Chen, Xi},
    booktitle={Advances in Neural Information Processing Systems},
    pages={2234--2242},
    year={2016}
    }

    Conference paper

  8. Conditional Generative Adversarial Nets

    Mehdi Mirza, Simon Osindero

    arXiv:1411.1784 Β· 2014

    BibTeX
    @misc{mirza2014conditional,
          title={Conditional Generative Adversarial Nets}, 
          author={Mehdi Mirza and Simon Osindero},
          year={2014},
          eprint={1411.1784},
          archivePrefix={arXiv},
          primaryClass={cs.LG}
    }

    Reference

  9. f-GAN: Training generative neural samplers using variational divergence minimization

    Sebastian Nowozin, Botond Cseke, Ryota Tomioka

    Advances in Neural Information Processing Systems, vol. 29 Β· 2016

    BibTeX
    @inproceedings{nowozin2016fgan,
      title={f-GAN: Training generative neural samplers using variational divergence minimization},
      author={Nowozin, Sebastian and Cseke, Botond and Tomioka, Ryota},
      booktitle={Advances in Neural Information Processing Systems},
      volume={29},
      year={2016}
    }

    Conference paper