Quant Memo
Advanced

The GAN Minimax Objective

A generative adversarial network trains two networks against each other in a game — a generator trying to fool a discriminator, and a discriminator trying not to be fooled — and the objective that describes this tug-of-war is a single minimax expression.

Prerequisites: Generative vs Discriminative Modeling, Gradient Descent

Most generative models are trained by directly maximizing a likelihood — how probable is the real data under the model. GANs do something structurally different: instead of one network learning a likelihood, two networks compete. A generator tries to produce fake samples realistic enough to pass as real. A discriminator tries to correctly tell real samples from the generator's fakes. Neither network is ever told "here is the correct probability of this data" — they only ever learn from beating, or losing to, each other.

The analogy: a forger and an inspector

Picture an art forger and a museum inspector locked in an ongoing contest. The forger studies rejected pieces and improves their technique to fool the inspector next time. The inspector studies both real paintings and the forger's latest attempts, sharpening their eye to catch subtler and subtler fakes. Neither party is ever handed a rulebook for "what makes a painting authentic" — both only ever react to the other's latest move. If this contest runs long enough with both sides improving, the forger's fakes become indistinguishable from the real thing, and the inspector is reduced to guessing.

The objective, symbol by symbol

The generator GG maps random noise zp(z)z \sim p(z) to a fake sample G(z)G(z). The discriminator DD outputs a probability that a given sample is real. Both are trained on one shared objective, minimized by GG and maximized by DD:

minGmaxD  V(D,G)=Expdata[logD(x)]+Ezp(z)[log(1D(G(z)))]\min_G \max_D \; V(D,G) = \mathbb{E}_{x \sim p_{\text{data}}}\big[\log D(x)\big] + \mathbb{E}_{z \sim p(z)}\big[\log(1 - D(G(z)))\big]

In words: DD wants to output values close to 11 for real data (making the first term large) and close to 00 for fakes (making the second term large too, since log(10)=0\log(1-0)=0 is the max of that piece). GG wants the opposite of the second term — it wants D(G(z))D(G(z)) close to 11, i.e. it wants the discriminator fooled, which minimizes log(1D(G(z)))\log(1-D(G(z))) toward -\infty. They optimize the same expression in opposite directions, which is what "minimax" means: one player's gain is the other's loss.

Worked example 1: one discriminator update by hand

Suppose on one real sample xx, D(x)=0.9D(x) = 0.9, and on one fake sample, D(G(z))=0.4D(G(z)) = 0.4 (the discriminator is currently mediocre at spotting fakes). The value function for this pair:

V=log(0.9)+log(10.4)=log(0.9)+log(0.6)=0.105+(0.511)=0.616V = \log(0.9) + \log(1 - 0.4) = \log(0.9) + \log(0.6) = -0.105 + (-0.511) = -0.616

The discriminator's gradient step pushes D(x)D(x) toward 11 and D(G(z))D(G(z)) toward 00 to raise VV. If it succeeds, say D(x)0.95D(x) \to 0.95 and D(G(z))0.2D(G(z)) \to 0.2: V=log(0.95)+log(0.8)=0.0510.223=0.274V = \log(0.95) + \log(0.8) = -0.051 - 0.223 = -0.274, a clear improvement (less negative) — the discriminator got better at telling them apart.

Worked example 2: the generator's opposing move

The generator only touches the second term, log(1D(G(z)))\log(1 - D(G(z))), and wants to minimize VV, meaning push D(G(z))D(G(z)) up. If it improves its fake so that D(G(z))D(G(z)) rises from 0.20.2 back to 0.50.5: log(10.5)=log(0.5)=0.693\log(1-0.5) = \log(0.5) = -0.693, versus log(10.2)=log(0.8)=0.223\log(1-0.2) = \log(0.8) = -0.223. VV's second term dropped from 0.223-0.223 to 0.693-0.693 — exactly what the generator wants, and exactly what makes the discriminator's job harder next round. This back-and-forth, one step improving DD's side and the next improving GG's, is why GAN training is a sequence of alternating gradient updates rather than one joint optimization.

noise z Generator Discriminator real data real/fake? gradient pushes G to fool D next time
Each round: the generator turns noise into a fake, the discriminator scores real and fake samples, and the resulting gradient updates both networks in opposite directions on the same objective.

Gradient descent
parameter →
position -0.623loss -0.141gradient -0.930converging

Watch the descent path above: GAN training alternates two such descents on the same loss surface, one player stepping downhill while the other tries to reshape the hill under them — which is part of why GAN optimization is notoriously less stable than descending a single fixed loss.

A GAN's minimax objective has the discriminator maximizing its ability to separate real from fake while the generator minimizes that same expression by fooling it — two networks trained on opposite ends of one shared scoreboard, with no direct likelihood ever computed for either.

What this means in practice

The minimax framing is why GANs can produce sharper, more realistic samples than likelihood-based models in many domains — there's no pressure to average over all plausible outputs, only pressure to be indistinguishable from real ones. It's also why GANs are used for synthetic financial time series (see quant-gan-for-financial-time-series): the discriminator can be handed features like autocorrelation or volatility clustering to check for, forcing the generator to reproduce those stylized facts rather than just matching a mean and variance.

The classic confusion is treating a GAN's discriminator loss as a measure of overall generation quality the way a validation loss works elsewhere. It is not: a discriminator loss near log20.693\log 2 \approx 0.693 per term can mean either "the generator is producing perfect samples the discriminator can't distinguish" or "training has stalled and nothing useful is happening" — the number alone can't tell you which, and practitioners rely on separate quality metrics rather than the adversarial loss curve itself.

Related concepts

Practice in interviews

Further reading

  • Goodfellow et al., Generative Adversarial Networks (2014)
ShareTwitterLinkedIn