Learn
Lesson 04 / 14Core20 min

The Minimax Game

min_G max_D V(D, G): two players, one value function

By the end of this lesson you can

  • Read and interpret the value function V(D, G) from Eq. 1
  • Understand why D maximises and G minimises the same quantity
  • Recognise a saddle point as the solution of a two-player zero-sum game
Visual explainer
Loading lab
Explanation

Put the generator and the discriminator together and you get the central equation of the paper. One value function, two players pulling it in opposite directions.

Equation 1

The paper writes the training problem as a two-player minimax game with value function V(G, D):

min_G max_D V(D, G) = E_x∼p_data(x)[log D(x)] + E_z∼p_z(z)[log(1 − D(G(z)))]

Take it apart term by term:

  • E_x∼p_data[log D(x)]: on real data, how confidently does D say "real"? It is 0 when D(x) = 1 and very negative when D(x) ≈ 0.
  • E_z∼p_z[log(1 − D(G(z)))]: on generated data, how confidently does D say "fake"? It is 0 when D(G(z)) = 0 and very negative when D(G(z)) ≈ 1.

Both logs are of numbers in (0, 1), so V ≤ 0 always. V close to 0 means D is winning decisively.

Each Player's View

The discriminator maximises

D controls both terms. It pushes D(x) toward 1 on real data and D(G(z)) toward 0 on fakes. As the previous lesson showed, this is the same as minimising binary cross-entropy.

The generator minimises

G cannot touch the first term: real data does not depend on θ_g. It can only change the second term, by moving its samples to places where D(G(z)) is high. From G's point of view the objective is:

min over θ_g of E_z∼p_z[log(1 − D(G(z; θ_g)))]

This is the paper's "train G to minimise log(1 − D(G(z)))". G never sees a real example. Everything it knows about the data arrives through D.

A Zero-Sum Game

D's payoff is V, G's payoff is −V. Whatever one gains the other loses. That makes this a two-player zero-sum game, the setting of classical game theory. The order of the operators matters: in min_G max_D, D gets to respond to whatever G does. G is choosing the generator whose best-case detector does worst.

The Solution Is a Saddle Point

We are not looking for a minimum of V, nor a maximum. We want a pair (G*, D*) where neither player can improve by moving alone:

V(D, G*) ≤ V(D*, G*) ≤ V(D*, G)    for every D and every G

Along D's direction the point is a maximum; along G's direction it is a minimum. Geometrically this is a saddle point, like the middle of a horse saddle: uphill along one axis, downhill along the other. In game theory it is a Nash equilibrium.

Lessons 5 and 6 show what this equilibrium is for GANs: the generator reproduces the data (p_g = p_data), the discriminator outputs 1/2 everywhere, and V = −log 4. Try it now: plug D(x) = 1/2 into Eq. 1 and you get log(1/2) + log(1/2) = −log 4, no matter what G is.

Why a game instead of a loss: G has no fixed target to regress onto. Its loss is defined by an opponent that keeps adapting. This is what lets GANs learn without a likelihood, and also why they are notoriously harder to train than a single network (lesson 10).
Common mistake: tracking V (or the generator's loss) and expecting it to fall steadily like a normal training loss. In a game, V can stay flat or oscillate while both players improve. A decreasing generator loss can simply mean D has become worse.
Interactive code

Edit the code and press Ctrl + Enter to run it in your browser.

pynumpy · matplotlib
Exercises
1

Compute V(D, G) for the constant discriminator D(x) = 1/2, for an arbitrary generator. What does this imply about max_D V(D, G) for every G?

2

In the code cell, D(x) = σ(w·x) has no bias. Add a bias c and search over (w, c). How does max_D V change for θ = 1 and θ = 2? Why was the no-bias D weaker?

3

Explain in your own words why the equilibrium of a GAN is a saddle point of V rather than a minimum or a maximum. What would go wrong if both players minimised V?

Key takeaway

GAN training is a zero-sum game: D pushes V up by classifying well, G pushes V down by fooling D, and the solution is a saddle point.

Up next

If D plays perfectly for a fixed G, what does it look like? There is a closed form.