Understand the technology
Follow one complete adversarial training round.
For May and November 2027. This lesson is higher level only. SL students are not required to study GANs.
01 | LEARNING THROUGH OPPOSING OBJECTIVES
A GAN does not improve because two networks simply compete for a score. Each network has a numerical learning objective, and training uses gradients to change its parameters.
The discriminator learns to distinguish dataset images from generated ones. The generator learns to produce candidates that receive a more favourable discriminator assessment. Their interaction is called an adversarial dynamic .
This HL lesson follows a basic probability-style GAN. Other formulations use different losses and outputs, but the distinction between the two learning roles remains essential.
02 | BEGIN WITH THE CURRENT NETWORKS
At the beginning of a training round, both networks have current parameter values. Early in training, the generated images may be poor and the discriminator may also make unreliable judgements.
A round uses real-data examples and sampled generator inputs. These provide material for predictions, losses and updates.
The generator is not supplied with a matching correct photograph for every noise vector in this basic setup. Its objective comes from the discriminator’s response, rather than a direct pixel-by-pixel comparison with one assigned target image.
03 | PHASE A: PREPARE DISCRIMINATOR EXAMPLES
Draw a batch of real images from the training dataset. Sample noise vectors and run the current generator to produce a batch of synthetic images.
The training process knows which source produced each example. In a simple binary-label explanation, real examples have target 1 and generated examples target 0.
These labels identify source membership. They do not certify that real images are factually true or that generated ones are unusable.
04 | PHASE A: MAKE DISCRIMINATOR PREDICTIONS
The discriminator processes both batches. In our formulation, it outputs a real-class score between 0 and 1.
For a real example, a score close to 1 agrees with its source label. For a generated example, a score close to 0 agrees with its source label.
The discriminator can make mistakes on either group. It needs to learn distinctions from both, rather than only becoming confident on real examples.
05 | PHASE A: CALCULATE THE DISCRIMINATOR LOSS
A common objective uses binary cross-entropy. For a real example with score p, its contribution is
−ln(p)
. For a generated example, it is
−ln(1 − p)
.
A confident correct prediction has a smaller contribution than a confident incorrect one. Losses are combined across the batch using a stated convention.
You do not need to derive logarithms here. Understand that the objective measures agreement with known source labels, rather than awarding aesthetic marks.
06 | PHASE A: UPDATE ONLY THE DISCRIMINATOR
Backpropagation computes gradients for the discriminator objective. Its optimizer then updates discriminator parameters.
The generated examples are treated as fixed inputs for this phase, commonly by detaching them from the generator’s gradient computation. The generator is not updated by the discriminator step.
07 | PHASE B: GENERATE CANDIDATES FOR LEARNING
For the generator phase, sample inputs and produce candidates with a gradient path back to generator parameters. Pass these candidates through the current discriminator.
The discriminator now supplies an assessment of the generator’s output. It still performs computations, even though its parameters are held fixed for the generator update.
Freezing parameters is different from cutting off every gradient through the discriminator. The generator needs information about how changes in its output would affect its objective.
08 | PHASE B: DEFINE THE GENERATOR OBJECTIVE
A commonly used non-saturating generator objective minimises
−ln(D(G(z)))
. In words, it encourages generated candidates to receive higher real-class scores.
This does not change the source of the image. The candidate remains generated; the objective asks the generator to make it harder for the discriminator to distinguish.
The original minimax formulation uses a different generator expression. Both are adversarial objectives; this lesson uses the non-saturating version to make the learning direction clear.
09 | PHASE B: PASS THE GRADIENT BACK
The generator loss depends on the discriminator’s response, which depends on the generated image, which depends on generator parameters.
Backpropagation follows that chain. The generator optimizer uses the resulting gradients to adjust generator parameters. Discriminator parameters remain unchanged during this phase.
No written advice such as “fix the eyes” is sent between networks. The feedback is numerical information about the chosen objective.
10 | COMPARE THE TWO UPDATE PHASES
| Aspect | Discriminator phase | Generator phase |
|---|---|---|
| Goal | Distinguish dataset and generated sources | Obtain more favourable assessments for generated outputs |
| Examples used | Real and generated examples | Generated examples assessed by the discriminator |
| Parameters updated | Discriminator | Generator |
| Other network | Generator supplies fixed examples | Discriminator is fixed but remains in the gradient path |
A practical setup can use more than one update of a network per round. There is no universal update ratio that guarantees balance.
11 | WHY THE TARGET KEEPS MOVING
After the discriminator improves, the generator faces a changed assessment function. After the generator improves, the discriminator receives a changed distribution of synthetic examples.
This moving interaction differs from learning against one fixed set of labelled inputs. Each network’s changes influence the other’s next task.
Improvement need not be smooth or monotonic. A temporary increase in one loss can reflect a stronger opponent, not necessarily a simple implementation failure.
12 | A SMALL SCORE EXAMPLE
Consider an invented generated candidate with discriminator score 0.2. Its fake-example discriminator contribution is
−ln(0.8)
, approximately
0.223
. Its non-saturating generator loss is
−ln(0.2)
, approximately
1.609
.
If a generated candidate instead scores 0.8, these values switch: approximately 1.609 for the fake-example discriminator contribution and 0.223 for the generator loss.
This illustrates opposing objectives at fixed scores. It does not calculate gradients, prove that an update caused the change or predict the next training result. Natural logarithms are used.
13 | BALANCE IS NOT SIMPLY EQUAL LOSSES
A very weak discriminator may provide poor information about realism. A discriminator that separates sources extremely confidently can also create difficulties, depending on the objective and learning dynamics.
The aim is useful learning pressure, not forcing two displayed loss numbers to match. Loss scales depend on formulation, batch aggregation and training conditions.
Investigate update rates, data and generated samples together. The next lesson examines training instability and mode collapse in more depth.
14 | WHAT DOES A SCORE NEAR 0.5 MEAN?
In the idealised original GAN analysis, if generated and real distributions match, the optimal discriminator cannot distinguish their sources and outputs 0.5.
However, an untrained or ineffective discriminator can also produce scores near 0.5. Therefore that number alone is not evidence of successful image generation.
Likewise, a low generator loss might reflect a weak discriminator rather than excellent images. Review sample quality and diversity independently.
15 | WATCH FOR QUALITY AND VARIETY
A generator could learn to produce a narrow set of convincing outputs while failing to represent the variety needed by the studio. This limited variation is associated with mode collapse.
Inspect repeated samples from varied noise inputs and representative conditions. One attractive selected image hides whether most outputs are repetitive or defective.
Use fixed evaluation conditions and appropriate held-out evidence where possible. Adversarial scores are training signals, not complete creative performance measures.
16 | TRAINING ENDS; GENERATION CONTINUES
Save appropriate checkpoints and select a model using a broader evaluation than one favourable loss value. Saving optimizer state can also support resuming training.
After training, a basic GAN generator can produce candidates from sampled vectors without the discriminator being required for each output.
Ordinary generation uses learned parameters rather than alternating optimizer updates. A separate deployment review process can still check the resulting images.
17 | APPLY IT TO VISIONARY STUDIOS
The booklet supplies no chosen optimizer or update ratio for the company. Treat detailed training choices here as explanatory examples.
18 | EXPLAIN ONE COMPLETE ROUND
In your book, describe a discriminator update followed by a generator update. State the objective, the information used and which parameter set changes in each phase.
Then explain why “freeze the discriminator” does not mean “remove it from the generator’s calculation”, and why a score of 0.5 is not sufficient proof of success.
Reveal a possible explanation
First, the discriminator assesses real and generated examples using known source labels and updates its own parameters. Next, generated candidates pass through the fixed discriminator; a generator objective supplies gradients through that computation to update generator parameters.
The fixed discriminator is still needed for the generator’s learning signal. A score near 0.5 could indicate genuine indistinguishability or simply a poor discriminator, so samples and wider evaluation are necessary.
HL only. Read alongside the adversarial training discussion in the official 2027 booklet. Scores and loss examples here are independent teaching material.
CHECK YOUR UNDERSTANDING | WHICH PHASE IS THIS?