For the minimax GAN objective min⁡Gmax⁡DV(D,G)=Ex∼pdata[log⁡D(x)]+Ez∼pz[log⁡(1−D(G(z)))], how do you derive the optimal discriminator DG∗(x) for a fixed generator G, and show that substituting DG∗ reduces the generator objective to 2DJS(pdata∥pg)−log⁡4?

Deep learning, Generative adversarial networks
Level L3 Intermediate. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can carry out Goodfellow et al.’s classic two-step proof connecting GAN training to Jensen–Shannon divergence.

Key idea

Rewrite the generator expectation over z as an expectation over x∼pg (the induced generator distribution), maximise the integrand alog⁡y+blog⁡(1−y) pointwise in y=D(x)∈(0,1) to find DG∗(x)=pdata(x)pdata(x)+pg(x), and substitute back to get a sum of two KLs.

Steps

  1. Rewrite V(D,G) as a single integral over x: V(D,G)=∫[pdata(x)log⁡D(x)+pg(x)log⁡(1−D(x))] dx, where pg is the distribution of G(z) when z∼pz.
  2. Maximise pointwise over y=D(x)∈(0,1) for fixed a=pdata(x) and b=pg(x) (with a+b>0, since points with a=b=0 contribute nothing to the integral): set ddy[alog⁡y+blog⁡(1−y)]=ay−b1−y=0, giving y∗=aa+b, i.e. DG∗(x)=pdata(x)pdata(x)+pg(x). The second derivative −ay2−b(1−y)2<0 confirms a maximum.
  3. Substitute DG∗(x) into V(DG∗,G) and introduce m(x)=12(pdata(x)+pg(x)): log⁡DG∗(x)=log⁡pdata(x)2m(x)=log⁡pdata(x)m(x)−log⁡2, and log⁡(1−DG∗(x))=log⁡pg(x)m(x)−log⁡2.
  4. Integrate: C(G)=V(DG∗,G)=∫pdata(x)log⁡pdata(x)m(x) dx+∫pg(x)log⁡pg(x)m(x) dx−log⁡4=DKL(pdata∥m)+DKL(pg∥m)−log⁡4=2DJS(pdata∥pg)−log⁡4.
  5. Conclude: since Jensen–Shannon divergence DJS≥0 with equality if and only if pg=pdata, the global minimum of C(G) is −log⁡4, attained uniquely at pg=pdata (where DG∗(x)=12 everywhere).

Common mistakes

How long your answer should be

One page; 6–8 minutes.

Last checked on 4 December 2026.

Read this

Previous in Deep learning: In a VAE with prior p(z)=N(0,I) and diagonal Gaussian encoder qϕ(z∣x)=N(μ,diag⁡(σ12,…,σd2)), how do you derive the closed-form KL divergence DKL(qϕ(z∣x) ∥ p(z)), and what does each term encourage?
Next in Deep learning: In SimCLR with a mini-batch of N images (giving 2N augmented views), write the NT-Xent (InfoNCE) loss for a positive pair (i,j) with cosine similarity si,j and temperature τ. Why is this a (2N−1)-way cross-entropy loss, and how does τ affect the gradients?