Skip to content
← Generative AI
Q21

The adversarial training loop and how G improves over time

GANTraining ProcessConvergence
Describe the adversarial training process in GANs. Explain how the Generator gradually learns to generate realistic samples through feedback from the Discriminator.

What's actually being asked

A step-by-step account of the GAN training loop (what happens each iteration) and specifically how G's output quality improves over many rounds of feedback from D.

Answer

One training iteration, step by step

  1. Sample a minibatch of real data x ~ p_data and a minibatch of noise z ~ p_z.
  2. Generate fakes: x_fake = G(z).
  3. Update D: with G's weights frozen, compute V(D,G) = 𝔼[log D(x)] + 𝔼[log(1−D(G(z)))] on this minibatch, and take a gradient-ascent step on D's parameters — D gets slightly better at telling this round's real from this round's fake.
  4. Update G: with D's weights now frozen at their just-updated values, sample fresh noise, generate fresh fakes, and take a gradient step on G's parameters using the non-saturating objective max_G 𝔼[log D(G(z))] (or the original min_G 𝔼[log(1−D(G(z)))]) — G adjusts its weights in the direction that would have made D's current judgement of its fakes more favourable.
  5. Repeat for many thousands of iterations, re-sampling real and noise batches each time.

Why alternating, not joint

D and G are never updated from a shared objective in one simultaneous pass — each update step treats the other network as a temporarily fixed function. This matters because the "game" only makes sense if each player optimizes against the current strategy of its opponent, not a stale or simultaneously-moving target. In practice, frameworks implement this by simply ordering the two optimizer-step calls and detaching gradients appropriately between them.

How G gets better over time — the feedback mechanism

Early in training, G's weights are random, so G(z) is noise-like garbage; D, seeing an easy contrast between this and real data, quickly learns to assign D(G(z))≈0 almost everywhere. That gradient, backpropagated through D's frozen weights into G, tells G exactly which direction in its parameter space would have nudged this batch's fakes to look slightly more "real" according to D's current decision boundary. G takes a small step in that direction. Because this repeats every iteration, with D continually re-sharpening its boundary against G's latest fakes, G is chasing a target that keeps moving to stay just ahead of it — each step, G closes the gap on D's present weaknesses, and D, in turn, has to find new weaknesses to flag. Over many rounds this co-evolution is what pushes G(z)'s distribution to gradually match p_data more and more closely, rather than G ever being told directly "this pixel should be darker" the way a supervised loss would.

Signs of healthy vs unhealthy training

  • Healthy: D's accuracy on real-vs-fake hovers moderately (not pinned at 100%, not stuck at chance) — both networks are still learning from each other.
  • Unhealthy: D becomes too strong too fast (saturates to near-perfect classification) — D(G(z))→0 everywhere, G's gradient vanishes (the saturation problem addressed by the non-saturating loss), and G stops improving. This is why the non-saturating generator loss and a careful learning-rate/architecture balance between G and D matter in practice.
  • Mode collapse: G may find it easier to fool D by producing only a few highly convincing sample types rather than the full diversity of p_data — a known failure mode of this alternating training process.

Exam tip

If asked specifically "how does G gradually improve," the expected answer is the gradient-relay-through-D mechanism above, not just "it trains with backprop" — name the alternating update and the moving-target intuition explicitly.