Skip to content
← Generative AI
Q19

GAN minimax game: Generator vs Discriminator

GANMinimaxAdversarial Training
Discuss the working principle of Generative Adversarial Networks. Illustrate the minimax game between the Generator and Discriminator with a suitable diagram and explain the objective function.

What's actually being asked

How GANs work as a two-player game, a diagram of the Generator-vs-Discriminator setup, and a full explanation of the minimax objective function.

Answer

The working principle

A GAN has two networks trained against each other:

  • Generator G takes random noise z ~ p_z (usually N(0,I) or uniform) and transforms it into a fake sample G(z), trying to make it look like it came from the real data distribution p_data.
  • Discriminator D takes a sample (real x, or fake G(z)) and outputs a scalar D(·) ∈ (0,1), its estimate of the probability that the sample is real.

They're trained with opposing goals: D wants to correctly tell real from fake; G wants to fool D into saying "real" about its fakes. Neither network sees hand-labelled "fake vs real" training examples in the usual supervised sense — the only supervision is this adversarial back-and-forth, which is what makes it a minimax game: G minimizes what D maximizes.

The diagram above traces this: noise z flows through G to produce a fake sample; both the fake and a real sample are fed into D; D's classification output feeds a loss/gradient signal back to update both networks.

The objective function

min_G max_D V(D,G) = 𝔼_{x∼p_data}[log D(x)] + 𝔼_{z∼p_z}[log(1 − D(G(z)))]

Reading it term by term:

  • 𝔼_{x∼p_data}[log D(x)] — D wants this high, i.e., D(x)→1 for real x.
  • 𝔼_{z∼p_z}[log(1−D(G(z)))] — D also wants this high, i.e., D(G(z))→0, correctly flagging fakes.
  • D's move: max_D the full V(D,G) — it maximizes log D(x) + log(1−D(G(z))), pushing it toward confidently separating real from fake.
  • G's move: min_G the same V(D,G) — since G can't affect the first term (it only depends on real data and D), this reduces to minimizing log(1−D(G(z))), i.e., G wants D(G(z))→1 (fooling D into calling fakes "real").

Why it's a genuine game, not just two separate losses

The two networks are updated alternately: freeze G, take a gradient-ascent step on D's objective; then freeze D, take a gradient step on G's objective; repeat for many iterations. Each network's loss landscape keeps shifting because the other network is also changing — textbook minimax/Nash-equilibrium territory, not ordinary single-objective optimization. At the theoretical optimum, D can no longer tell real from fake at all: D(x) = D(G(z)) = 0.5 everywhere, and G's output distribution matches p_data exactly.

A practical twist — the non-saturating generator loss

Early in training, D rejects G's (still poor) fakes confidently, so D(G(z)) ≈ 0, and log(1−D(G(z))) sits in a region where its gradient w.r.t. G's parameters is nearly flat (saturates) — G barely learns. In practice, G is instead trained to maximize log D(G(z)) (the non-saturating loss) — the same fooling goal, but with much stronger gradients exactly when G most needs them (when it's doing badly).

Exam tip

State explicitly that G never sees real data directly — it only ever gets a gradient signal relayed through D. This single fact is a favourite "trick" short-answer question on its own.

ARCHITECTUREhow the pieces talk
6 components. Noise z to Generator G; Generator G to Fake G(z) (generate); Fake G(z) to Discriminator D; Real x to Discriminator D; Discriminator D to Real/Fake score (classify); Real/Fake score to Generator G (feedback).Noise zGenerator GFake G(z)Real xDiscriminator DReal/Fake scoregenerateclassifyfeedback