Skip to content
ExamSpine

Generative adversarial networks (GANs)

Two networks, one making fakes and one spotting them, get better by competing. When it works, the forger wins.

Challenge 3HL only

Two networks with opposite goals

  • The generator takes a vector of random numbers (the latent vector, often called z) and turns it into an image.
  • The discriminator takes an image and outputs a probability that it is real, from the training set, rather than made by the generator.

Key idea: The discriminator is trained to tell real from fake; the generator is trained to fool the discriminator. Neither ever sees a rule for what makes a good image. The generator only learns from the discriminator's reactions.

How training alternates

Each round of training has two parts:

  1. Train the discriminator. Show it a batch of real images (target: real) and a batch the generator just made (target: fake). Update only the discriminator's weights to classify better.
  2. Train the generator. Generate a batch, pass it through the discriminator, and measure how "fake" it was judged. Backpropagate that error through the discriminator into the generator, and update only the generator's weights, so its next images look more real to the discriminator.

This is a minimax game: the discriminator tries to maximise how well it tells real from fake, and the generator tries to minimise it. In theory the end point is an equilibrium where the generator's images match the real distribution and the discriminator can do no better than guessing (0.5).

Strengths and weaknesses

GANDiffusion
Generation speedOne pass through the generator: very fastMany denoising passes: slower
Image qualityVery sharp in a narrow domain (faces, one product type)Very high, across a wide range of subjects
Variety (diversity)Can collapse to a few outputsCovers the data well
TrainingUnstable, sensitive to settingsStable, a simple loss
Text controlHarder at scaleStrong, via cross-attention

Key idea: GANs win on speed; diffusion wins on stability, variety and following prompts. That trade-off is why many modern systems combine them, as the hybrid models topic explains.

A conditional GAN feeds extra information (a class label, a sketch, or a text embedding) to both networks, so you can ask for a particular kind of image.

Key terms

Generative adversarial network (GAN)
A generator and a discriminator trained against each other: one makes images, the other tries to tell them from real ones.
Generator
The GAN network that turns a random latent vector into an image, trained to fool the discriminator.
Discriminator
The GAN network that classifies images as real (from the training data) or fake (from the generator).
Latent vector (z)
The random input to a GAN's generator. Different vectors give different images.
Minimax game
The GAN set-up where the discriminator tries to maximise how well it tells real from fake and the generator tries to minimise it.
Equilibrium (GAN)
The ideal end of GAN training, where generated images match the real distribution and the discriminator can only guess (0.5).
Conditional GAN
A GAN where both networks also receive extra information, such as a label or text embedding, so you can ask for a particular kind of image.

See all 65 terms in the glossary

Exam-style questions

In the style of Paper 1 Section B. Write your answer first, then open the marking points and mark yourself honestly. The questions use our own company, Hearth & Oak: an online furniture shop that wants to generate room scenes around its products.

Worked example · Describe · AO1 · HL

[4 marks]

Describe how the generator in a GAN is trained.

How to approach it

Describe the steps in order. The point most students miss is that the gradient flows through the discriminator, and that the discriminator is frozen while the generator updates.

0 words

Marking points and model answer

A model answer

The generator is given random latent vectors and produces a batch of images. These are fed into the discriminator, which outputs how likely each is to be real. The generator's loss is low when the discriminator is fooled, so the error is backpropagated back through the discriminator into the generator, and only the generator's weights are updated while the discriminator's are held fixed. This step alternates with a step that trains the discriminator on real and generated images.

For each point, does your answer make it? Be strict: a marker would be.

  • Point 1: The generator turns random latent vectors (noise) into images. (1 mark)
  • Point 2: The images are passed to the discriminator, which scores how real they look. (1 mark)
  • Point 3: The loss rewards fooling the discriminator; the error is backpropagated through the discriminator to the generator. (1 mark)
  • Point 4: Only the generator's weights are updated in this step (discriminator fixed); this alternates with training the discriminator. (1 mark)

Earns nothing

  • Comparing generated images directly with real ones pixel by pixel.

Mark every point to see your total.

Question 1 · State · AO1 · HL

[1 mark]

State the role of the discriminator in a GAN.

0 words

Marking points and model answer

A model answer

The discriminator classifies an image as real, from the training data, or fake, made by the generator.

For each point, does your answer make it? Be strict: a marker would be.

  • Point 1: To classify images as real (from the training data) or fake (from the generator), giving the generator feedback. (1 mark)

Earns nothing

  • "To check the image is good."

Mark every point to see your total.

Question 2 · Explain · AO2 · HL

[3 marks]

Hearth & Oak wants to show live previews that update as a customer drags a slider for "how modern" a room is. Explain why a GAN might be more suitable than a diffusion model for this feature.

0 words

Marking points and model answer

A model answer

A GAN makes an image with one pass through its generator, while a diffusion model needs many passes, one per denoising step. A live preview has to produce a new image every time the slider moves, many times a second, which a single pass can manage and many passes cannot. A GAN's latent space also tends to change smoothly, so small slider moves give small, gradual changes in the room.

For each point, does your answer make it? Be strict: a marker would be.

  • Point 1: A GAN generates an image in a single pass through the generator. (1 mark)
  • Point 2: A diffusion model needs many denoising passes, so it is much slower per image. (1 mark)
  • Point 3: Live slider updates need many images per second / low latency; also a GAN latent space changes smoothly as you move through it. (1 mark)

Mark every point to see your total.

Question 3 · Compare and contrast · AO1 · HL

[4 marks]

Compare and contrast GANs and diffusion models as approaches to image generation.

0 words

Marking points and model answer

A model answer

Both are neural networks that turn random noise into new images after training on large datasets. A GAN produces an image in one pass of its generator, while a diffusion model removes noise over many steps, so GANs are much faster at generation time. GANs are trained adversarially against a discriminator, which is unstable, whereas diffusion models are trained with a simple, stable denoising loss. Diffusion models usually produce more varied images and follow text prompts better, while GANs can collapse to a small range of outputs.

For each point, does your answer make it? Be strict: a marker would be.

  • Point 1: Both learn to generate new images from random noise / both are trained on large image datasets. (1 mark)
  • Point 2: Speed: GAN one pass vs diffusion many steps. (1 mark)
  • Point 3: Training: GANs adversarial and unstable vs diffusion stable with a simple denoising loss. (1 mark)
  • Point 4: Output: diffusion more diverse / better prompt following vs GAN risk of mode collapse. (1 mark)

Earns nothing

  • Points about only one model with no comparison.

Mark every point to see your total.

All case study topics

  1. Challenge 1

    SL and HL

    How diffusion models make an image

    Noise, denoising, the network that predicts the noise, and how a text prompt steers it.

  2. Challenge 2

    SL and HL

    Training data: ethics, ownership and bias

    Consent, copyright and attribution for training images, and how curation choices shape what the model makes.

  3. Challenge 3

    HL only

    GANs: a generator against a discriminator

    How two networks train against each other, and why that training is unstable.

  4. Challenge 4

    HL only

    Hybrid models and the trade-offs between them

    Systems that combine diffusion, GANs and autoencoders, judged on quality, speed, diversity and complexity.

Written by Spine in our own words. Spine is not affiliated with or endorsed by the International Baccalaureate. Every question, set of marking points and model answer here is our own, set in our own made-up company. Facts about the case study itself come from public guides and are marked “reported”. Last checked 2026-10-23.