Skip to content
AI360XpertBeta
Playgrounds

Generative AI

Generative Adversarial Networks (GANs)

Change how often the discriminator updates and inspect the loss gradient it sends to each generated output.

Data seed 1

Guided steps 1 / 6

Stage 1 of 6: The Real Distribution

Data space (x, y)

Round 0. The generator populates 0 of 2 real clusters, with mean distance 1.002 to the nearest real sample and 63 percent of its samples nearer the left cluster.

  • Real sample
  • Generated sample
  • Field: scored as real
  • Field: scored as fake
  • Gradient sent to the generator
  • Discriminator loss
  • Generator loss
Modes covered0Modes covered: 0
Realism1.002Realism: 1.002

The target has two clusters.

The discriminator trains on samples from both clusters. The generator receives latent codes as input.

Check your understanding

A GAN generator learns from a discriminator’s gradient at its own outputs. Preview that gradient, run one training round and see when the signal disappears.

What each network sees

The discriminator learns to distinguish real samples from generated ones. The generator turns 40 fixed Gaussian latent codes into points. It learns about the real distribution through the discriminator’s response to those points.

At The Discriminator, the field shows the current classifier score. A pale cell is closer to 0.5. Predict the vertical signal for the highlighted fake after the discriminator updates. Step runs a full round, including one generator update.

Read the next generator signal

At The Signal, the field previews the discriminator after its next turn. The arrow starts at the current fake and points along the negative gradient of its non-saturating loss, −log⁡D(x)-\log D(x). The score D(x)D(x) is the sigmoid of the discriminator logit a(x)a(x). The descent vector is (1−D(x))∇xa(x)(1-D(x))\nabla_x a(x).

The generator backpropagates these vectors through its own network and averages the parameter gradients over the batch. The arrows describe local descent in data space. Updating shared generator weights can move a fake in a different direction from its individual arrow.

Signal to G averages the raw vector lengths over all 40 fakes. The scene draws every second arrow and bounds nonzero arrow lengths for legibility. Under the hood lists the raw direction, post-update score and active discriminator ReLUs for those samples. If all four ReLUs are inactive at a fake, the logit is locally flat and the gradient there is exactly zero.

Read both losses alongside the samples

At The Adversarial Loop, the loss curves measure the two networks after each completed round. A discriminator score of 0.5 on every sample gives both mean losses ln⁡2≈0.693\ln 2 \approx 0.693. Check the sample distribution too. A classifier can be indecisive early in training.

Modes covered counts populated target clusters. Realism is the average distance from each fake to its nearest real sample. A generator can have low distance while crowding into one cluster. A stalled generator can also end up far from both clusters. Samples outside the scene appear dimmed at its edge. The loss plot clips large values, while the readouts show the measured losses.

Compare update schedules

Try 12 discriminator steps starts a fresh paused run at the default rates. Play and watch the gradient and both coverage measures. Across the eight seeds, the runs at this setting cover fewer than two modes throughout rounds 200–300. At round 300, seven or more have exactly zero signal. Back to working restores your previous run, paused.

Try two discriminator steps per round from a fresh start. At the default rates, both clusters stay covered across the eight seeds in that same interval. These outcomes describe the lab’s fixed batches and networks. The original experiments used one discriminator update per round. Section 3 of the paper describes the non-saturating objective used for the generator here. Generative Adversarial Networks

Reset starts over with the current seed and settings. Reset controls also restores the defaults. New data cycles through the measured seeds. Share opens a fresh paused run with the selected stage, seed and settings.

Stage recap

  1. The Real Distribution

    The discriminator trains on samples from both clusters. The generator receives latent codes as input.

  2. The Generator

    The same 40 Gaussian latent codes pass through the generator each round. Their positions change as its weights change.

  3. The Discriminator

    The field shows the current estimated probability of real at each position. Step trains the discriminator first and then updates the generator once.

  4. The Signal

    The field previews the discriminator after its next turn. The arrows show output-space descent for every second fake. Signal to G averages the raw lengths across all fakes.

  5. The Adversarial Loop

    Step runs one round. The discriminator trains, then the generator uses the previewed signal. The curves measure both losses after the round.

  6. Starve the Generator

    Try 12 discriminator updates from a fresh run at the default rates. Compare the next signal with coverage and nearest-real distance.

Reference

Objective
min_G max_D V(D,G) = E_real[log D(x)] + E_z[log(1 - D(G(z)))]. A saddle point, not a minimum — which is why neither loss falling is good news on its own.
Discriminator loss
Binary cross-entropy over the real batch (target 1) and the fake batch (target 0), averaged over both. Near 0 means it is winning; near ln 2 means it cannot tell.
Generator loss (non-saturating)
Minimise -log D(G(z)). Its derivative with respect to the discriminator logit is D(G(z)) − 1. A locally flat logit can still block the gradient.
The signal
The arrows show −∂L/∂x at each drawn fake after the discriminator turn. Generator backpropagation uses the batch of vectors to update its weights.
ln 2 = 0.693
Both mean losses equal ln 2 if D outputs 0.5 on all samples. Inspect the generated distribution as well.
k, steps per round
Discriminator updates per generator update. Goodfellow et al. used k = 1 in their experiments.

Break it on purpose

The next generator turn has exactly zero output-space signal for this batch. Step to update the discriminator. If the signal stays zero, the generator weights stay fixed. Inspect the active ReLU counts to see whether the discriminator is locally flat at the generated samples.