Skip to main content
Unsupervised Deep Learning

Improving GAN Training: Optimal Discriminators, DCGAN, and the Wasserstein Distance

Published: 2026-08-25
Level: postgraduate
Audience: Postgraduate students in machine learning and deep learning

11.1 Where GANs Stand Among Generative Models

The roadmap from here is short to state. The study of GAN training continues in the coming meetings. Then the course turns to diffusion models together with energy-based models. After that come applications of these ideas in natural language processing and vision, and a full recap meeting closes the taught material. A dedicated problem-solving webinar drills exam-style questions for the finals. Keep that arc in mind, because everything built today (a better distance measure and a better GAN) is a direct fix for the failures listed below.

11.1.1 Explicit Versus Implicit Generative Modeling

Every model in this course so far answers one question: "what is the probability of this data?" A GAN refuses to answer it — and that refusal is the source of both its speed and its problems.

Every generative model met so far except the GAN is an explicit model trained by maximizing likelihood. Explicit means you can write down the probability density of your data under the model — an actual formula that you can evaluate at any point.

  • Autoregressive (AR) models factor the joint probability into a product of conditionals: , where each factor is a network output over the -th element given the earlier ones. They give an explicit and accurate distribution.
  • Flow models invert a stack of easy transformations. They also give an explicit, accurate distribution: start from a simple base density and apply an invertible map with a known Jacobian determinant, so the density of the output can be computed exactly.
  • Variational autoencoders (VAEs) maximize the data likelihood only in approximation, because the KL divergence term between the encoder and decoder distributions is intractable. The model still works, but it optimizes a bound instead of the true likelihood.

A useful everyday picture: an explicit model is like a bakery that publishes its exact recipe book — for any proposed cake, it can look up precisely how likely that cake is under its recipes. An implicit model is a forger with no recipe book at all: it can only produce convincing cakes, one after another. Ask the forger "how probable is this specific cake?" and it has nothing to say. That is exactly the trade the GAN makes.

A GAN takes the implicit route. No formula for the data density is ever written down or approximated. Instead two networks play a game:

  1. A generator maps a small random vector (say 100 numbers) to a fake sample .
  2. A discriminator looks at a sample and outputs how real it believes it is. Its goal: high output on true training data, near zero on generated data.
  3. The generator's goal is the opposite: pull the discriminator's output up on fakes.

This tug-of-war is written as a minimax optimization: one player minimizes, the other maximizes, over the same objective function. Because both maximization and minimization are involved at the same time, training such a network is hard in principle. Train one yourself and you will often watch the loss oscillate; it does not settle smoothly down to a minimum the way ordinary supervised losses do. That instability is not a bug in your code. It is baked into the game.

Scope: Going implicit has a price. Since no likelihood is learned, you cannot ask "how probable is this generated point?" by evaluating a density function. All earlier models could do that. So judging GAN output requires different tools, which leads straight to the two scores below. Keep this limitation in mind every time someone reports a GAN result: there is no number that says how likely a sample is, only numbers that say how convincing and how varied samples are.

11.1.2 Scoring Generated Samples: Inception Score and FID

Two properties define a good generator. First, its samples should be confidently recognizable: the discriminator should classify them into the real bucket without hesitation. Second, they should be diverse, matching the variety seen in the training data. The Inception Score (IS) packs both demands into one number. In plain words, the verbal form was: take e raised to the power of two entropies — the entropy of the label spread of generated data, minus the entropy of the per-sample label predictions. Reconciled against the standard definition, the formula is:

Here is a generated sample drawn from the generator's distribution , is the class label predicted by a separate pre-trained classifier (historically the Inception network, which gives the score its name), is the marginal label distribution averaged over all generated samples, is the label distribution for one specific sample, and is entropy, , where the sum runs over all classes.

The two entropy terms measure the two demands separately:

  • Low conditional entropy : each single image gets a confident, peaked class prediction — quality of individual samples.
  • High marginal entropy : across the whole collection, all classes appear roughly equally often — diversity of the set.

Why are the two forms equal? Expand the KL term and average it over samples. For each ,

The first move is the definition of KL divergence; the second swaps the order of averaging so that collapses exactly to the marginal , whose negative sum is again an entropy. This confirms the equivalence claimed in the lecture's verbal description.

Worked example. Generate two images from a two-class generator (). The classifier believes image 1 is a dog with probability 0.9, and image 2 is a cat with probability 0.9, so and .

Step 1 — marginal: .

Step 2 — marginal entropy: .

Step 3 — conditional entropy (same for both images): .

Step 4 — score: .

Sense-check: with classes the best possible IS is 2 (uniform marginal, one-hot conditionals), and the worst is 1. Our 1.44 sits sensibly between them — confident but not perfect predictions on a balanced pair.

The catch: a high IS does not guarantee images that look good to a human eye. Perceptual quality can lag behind the score. The FID score was formulated to close that gap: instead of comparing class labels, it compares feature statistics (means and covariances of activations) of real and generated images inside a pre-trained network, so it rewards images whose internal statistics genuinely match the training set. A low FID combined with a high IS tracks human judgment of quality much better than either number alone.

Real-world use: IS and FID remain the standard reporting metrics for image generators, so reading any generative-model paper means reading these two numbers. Every architecture comparison you will meet later in this course (DCGAN baselines, WGAN improvements) is scored on exactly this axis.

Explicit models hand you a density you can evaluate; the GAN hands you only a sampler. That single design choice explains the GAN's fast sampling, its missing likelihood, and why the field invented IS and FID to fill the evaluation hole.

11.2 What Makes a GAN Fast — and Where It Struggles

11.2.1 Generation Is One Forward Pass

Why did GANs take over image generation so quickly? Because producing one new image costs exactly as much as running a network once — nothing in the pipeline iterates.

Sampling from a GAN is fast because generation is just arithmetic through a deep network. Change the entries of a small random vector, say 100 by 1, and pass it through the trained generator. Out comes new data, possibly shaped like an RGB image of size 224 by 224 by 3 if that matches your training set. No iterative procedure, no posterior inference, no Markov chain. Just one forward pass. This is why GANs earned a reputation for fast sampling compared with every likelihood-based alternative.

It helps to see the contrast on dimensions that matter when you actually train these systems:

Dimension GAN Likelihood-based alternatives
Sampling cost One forward pass through Iterative: repeated network evaluations (AR models emit one element at a time; diffusion-style samplers take many denoising steps)
Density available? No Yes (exactly for AR/flows, approximately for VAEs)
Objective Directly "does this fool a judge?" Surrogate: log-likelihood (or a bound on it)
Training stability Fragile minimax game Ordinary gradient descent on a single loss

When to pick which: if you need fast bulk generation of perceptual media, the GAN route wins; if you need to score or rank individual points by probability, only the explicit side can do it.

The GAN objective also optimizes directly for what you actually care about: whether samples look real enough to fool a judge, rather than whether some surrogate log-likelihood went up. That alignment between goal and loss is a genuinely attractive property.

11.2.2 Known Weak Points

Scope: Upfront honesty about the basic formulation — these four weaknesses are the agenda for the rest of the lecture:

  • Performance on RGB images was historically not good.
  • Push the generated image size past roughly 64 by 64 and result quality drops off.
  • There is no inference machinery and no likelihood, so you cannot score how plausible an individual sample is.
  • The minimax game makes training unstable and sensitive, as the oscillating loss showed.

If a violation of any assumption below bites you, expect the corresponding failure: large colorful images expose the architecture's limits; downstream tasks that need sample-level probabilities find nothing to use; and every experiment inherits the instability of the adversarial game itself.

Everything in the rest of this document attacks these weak points, first with engineering (DCGAN, improved techniques) and then with mathematics (the Wasserstein distance).

Real-world placement: these trade-offs decided industrial practice. When a product needs millions of images quickly — game asset prototyping, data augmentation for rare defect classes in manufacturing inspection — the one-forward-pass sampler was worth the training pain, and teams accepted that they could not rank individual outputs by likelihood.

A GAN generates at the speed of one network pass but offers no density and no stability guarantees. The rest of this lecture is the story of paying down those two debts.

11.3 Theory of the Optimal Discriminator

Before improving anything, pin down what a perfect discriminator would even look like. To find it, build a functional — a number computed from a whole function — that captures the discriminator's total performance tied to the GAN's goal, then find which function maximizes it. The basics come straight from a machine learning prerequisite: optimal thresholds and Bayes-style decisions.

Think of this section as asking: "if the generator froze for a moment, what would the very best possible judge look like?" Knowing that ideal judge tells us what signal the generator actually receives — and later, exactly how far the generator's cost can fall.

11.3.1 The Discriminator's Objective Functional

Let denote a training sample drawn from the true data distribution . Let be the small random input vector fed to the generator, drawn from a simple prior such as uniform noise. Let be the generated fake and the discriminator's realness score for any input. The value functional for the discriminator is:

Average the logarithm of over all real training data, add the average of the logarithm of one minus the discriminator's score on generated data, and maximize this whole thing with respect to . If the discriminator were perfect, would sit near 0, making the second log term near in magnitude terms favorable, while on real data sits near 1.

To work with this, recall from a probability course how an expectation becomes an integral: for a random variable with density , the expected value is over the whole range. Applying that here:

Now one clean substitution. Generated values follow the generator's own distribution . Replace the variable by distributed according to ; this is just pushing the noise prior through :

All we did was replace with and with , the generator's probability distribution.

11.3.2 Deriving the Optimal Discriminator Step by Step

Look inside the integral at a single point . Make three renamings: call simply , call simply , and call simply . The integrand becomes:

Maximizing the integral means maximizing this expression at every independently, since can be chosen freely at each point. Why can we treat each point separately? Because the integral just adds up the integrand's contributions point by point — no choice of at one location changes the payoff at another. So the best global function is the pointwise best value everywhere.

The optimality condition for a smooth one-dimensional function is that its derivative equals zero. Differentiate term by term ( and, by the chain rule, ):

Setting that derivative to zero and solving gives the optimal value of . Here is every line of algebra:

This critical point really is a maximum, not a minimum: differentiate once more,

and both terms are strictly negative for every , and every . A negative second derivative everywhere means the function is concave, so the single critical point is the global maximum. As a boundary sanity check, as (when ) and as (when ), confirming the maximum lives strictly inside the interval.

Worked example (numbers at one point). Suppose at some pixel location the data density is and the generator density is . With and :

Check via the derivative: , so the optimality condition holds. Since 0.75 is above one half, the point gets called real — as expected, because data mass there is three times the generator's mass.

Undoing the renaming (, , ) yields the central result:

The best possible discriminator is a ratio of densities. It needs no training tricks; it is exactly what the game forces.

11.3.3 Geometric Meaning: The 0.5 Threshold

Recall from the ML toolkit the picture of two overlapping bell curves where the optimal classification threshold sits at the crossing point of the two density curves, giving minimum error. The formula says precisely that. Picture the horizontal axis as pixel space and the vertical axis as density. Wherever , the ratio exceeds one half, so the optimal discriminator calls the point real. Wherever wins, it calls the point fake. Exactly at the crossings the ratio equals one half — the decision flips there, which is why those crossing points are the minimal-error threshold locations from the prerequisite course.

Special case worth memorizing: if the generator has fully learned the data distribution, then everywhere and:

A perfect generator leaves the discriminator unable to tell anything apart, stuck at one half on every input. Output above one half goes to the data class; below, to the generated class.

11.3.4 The Best Achievable Generator Loss

Plug the optimal discriminator back into the value function. Writing for the midpoint distribution and using , the generator's cost becomes:

The first line substitutes the optimal discriminator; the second splits each logarithm using ; the third recognizes each remaining expectation as a KL divergence by definition. Collecting constants gives the form stated in the lecture:

The last equality holds because the Jensen–Shannon divergence is defined as half of each of these two KL terms against the midpoint: with . Doubling it reproduces exactly the pair of KL terms above.

Both KL terms are non-negative and vanish only when coincides with . So the floor of the generator's cost is:

Worked example (reading the floor). At the ideal endpoint : both KL divergences equal zero, so nats (equivalently bits, since ). Sense-check: , and any mismatch between and adds a positive KL amount on top, pushing the cost up toward and above zero. If you ever see the floor quoted as "minus log zero," treat it as a slip — substituting into the formula above leaves exactly , not zero.

For contrast, consider the non-GAN setting: training a plain maximum-likelihood classifier. That objective also bottoms out when the model distribution equals the data distribution. The idealized minimum there lines up with the same minus-log-four figure. In practice real runs stay above the floor because the generator never matches the data perfectly, leaving a gap between the two distributions. Knowing the floor calibrates how you read a training curve: a generator loss hovering well above means the two distributions still differ measurably.

Exam note: interviews probe this exact theory with tricky questions about the optimal discriminator ratio and the minus-log-four floor. Be ready to derive both — set the derivative of to zero for the first, substitute back into for the second.

11.4 Comparing Distributions: Forward KL, Reverse KL, Mode Collapse, Mode Covering

Why spend time on distance functions? Because the plan is to build an improved GAN variant whose objective uses a distance between two distributions, chosen deliberately instead of inherited blindly. Understanding what each distance rewards and punishes tells you which failure mode your GAN will develop.

11.4.1 A Toy Mixture of Two Gaussians

Take a one-dimensional example simple enough to draw. The true data distribution is a mixture of two Gaussians with nearly equal standard deviations, differing only in their means, mixed half and half:

Here is the Gaussian (bell-curve) density centered at mean with variance , and the two coefficients 0.5 are mixture weights — shares of total probability assigned to each bump, summing to one. So the training data piles up in two bumps with a nearly empty valley between them. Real datasets are usually multimodal like this, and the picture grows far more complex when the data has many dimensions instead of one.

Visual intuition: plot density on the vertical axis against on the horizontal axis. You see two peaks of almost equal height at and , separated by a valley that dips nearly to zero between them. The single number that matters later is each peak's share of total area — change the share and the peak heights move even though the centers stay fixed.

11.4.2 Forward KL Gives Mode Covering

The forward KL divergence from to a candidate model is:

The integral runs over all of . Read it as an average, weighted by the true density , of how badly underestimates at each point.

Minimizing it forces to put mass wherever has mass, including the low-lying tails. The reason sits inside the logarithm: wherever but approaches zero, the ratio explodes toward infinity, so leaving out any region the data touches costs an unbounded amount. For the two-bump toy problem, the minimizing spreads across both bumps and the valley between them. Now generate samples from that : many land on the modes, but plenty land in regions where real data is rare. Those samples are very unlikely under the true data distribution — they look unlike anything in the training set. Variety survives; perceptual quality suffers. This failure pattern is called mode covering: the generator covers every mode but pays for it with implausible samples filling the empty middle.

Worked mini-example (why dropping a mode costs infinitely). Compress the picture to two bins: left bump and right bump , with the true distribution . Compare two candidate fits:

  • Balanced fit :

. Perfect.

  • Collapsed fit , which abandons the right bump:

.

The zero in the denominator makes the penalty infinite. Sense-check: this matches the definition's warning that KL blows up wherever is zero while is not — so any fit scored by forward KL must keep some mass on every mode.

Real-world connection: this same pattern is an indication of hallucination. The word hallucination is used mostly for text generators, but an image generator emitting samples no one recognizes as meaningful data fails the same way, and over-wide coverage is one cause.

11.4.3 Reverse KL Gives Mode Collapse

Flip the argument order:

Same integrand, swapped roles: now the fit supplies the weighting, and the logarithm explodes where is near zero.

Now is terrified of placing mass where is near zero, because that makes the log ratio explode. The cheapest escape is to hug a single bump of tightly. The fitted collapses onto one mode. Samples look sharp and highly realistic — perceptual quality stays high — but every sample has the same flavor. Diversity dies. This is the famous mode collapse problem of GANs: the generator collapses to one of the modes of the training distribution. The complementary vocabulary: mode seeking behavior seeks one mode, and collapsing is what kills variety.

So remember this pairing, because the improved GAN later today is constructed directly around escaping it: forward KL keeps variety and loses quality; reverse KL keeps quality and loses variety.

Forward Reverse
Weighting inside the integral by true data by model
Where it blows up where where
Fitted shape spreads over all modes + valley hugs one mode tightly
Failure name mode covering mode collapse
Samples look sometimes implausible sharp but repetitive

Pick forward KL when missing real regions is the worst outcome; pick reverse KL when emitting garbage outside the data is the worst outcome. GANs inherit pressures from both, as the next subsection shows.

11.4.4 Jensen–Shannon Divergence: An Average With the Same Traps

The Jensen–Shannon divergence (JSD) is nothing more than an average of the forward KL and the reverse KL, taken against a midpoint distribution. Both failure pressures survive inside the average: one side pulls toward covering, the other toward collapsing. The original GAN objective, it turns out, ties to JSD — which is why the saturation problems developed below matter so much. The formal definition and its geometric quirks get their own treatment in Section 11.7.

11.4.5 Classroom Question: Why Did the Peak Move?

Two versions of the mixture picture were shown side by side. In the second, the blended curve's peak had drifted toward the left bump instead of sitting midway.

Q: Why is the peak of the blended curve moving toward one side? My guess was that the left Gaussian simply has a higher mean.

A: Close, but not quite — a higher mean is not what moved the peak. Each Gaussian keeps its own center. What differs between the two pictures is the mixture weight: the left component carries a larger mixture coefficient, a bigger share of the total probability, so the blend's peak gets dragged toward that heavier component. The mean of a mixture is itself a weighted average, so changing weights moves the peak without moving either component's center. Push that reasoning to the limit: when one weight swallows everything, the blend sits entirely on that single mode, and a reverse-KL fit happily stays there — that is mode collapse in miniature.

Several students made the same "higher mean" guess, so here is the correction once more, stated directly: peak position encodes mixture weights, and mixture weights are exactly what a collapsing generator lets degenerate.

Pitfalls to avoid with these distances:

  • Mixing up the argument order. In the first argument does the weighting; swapping the arguments swaps the failure mode from covering to collapsing.
  • Assuming the valley sample problem means the generator is broken. Under forward-KL pressure, implausible valley samples are the expected price of full coverage.
  • Treating mode collapse as random noise. It is the rational optimum for a reverse-KL-style objective — the objective, not the optimizer, is what rewards hugging one mode.
  • Forgetting that JSD contains both pressures; averaging them does not remove either trap.

Forward KL spreads mass and keeps variety (mode covering); reverse KL hugs a mode and keeps quality (mode collapse); JSD averages the two and inherits both traps. Every GAN failure you will debug lives somewhere on this axis.

11.5 DCGAN: Deep Convolutional GAN

The first upgrade is architectural. The deep convolutional GAN (DCGAN) is a GAN tuned specifically for image generation, built on CNN machinery. Recall the convolutional autoencoder assignment: there the goal was good reconstruction. Here the goal differs — generating fresh images from noise — but the building blocks overlap heavily.

11.5.1 Generator Architecture Walkthrough

The generator starts from a 100-dimensional random vector and ends at a 64 by 64 by 3 RGB image, matching a training set of 64 by 64 color images. Follow the tensor shapes:

Stage Operation Output shape
Input random noise vector
Projection MLP project and reshape
Upsample 1 fractionally strided convolution
Upsample 2 fractionally strided convolution
Upsample 3 fractionally strided convolution
Output fractionally strided convolution

Read the table as a story: the spatial size doubles at every step while the channel count halves — increasing spatial resolution, reducing depth. The first stage is a plain multi-layer perceptron with 100 inputs whose outputs are reshaped into a 4 by 4 grid with 1024 channels; those channels behave like feature maps. From there on, every layer is a fractionally strided convolution, also called a transposed convolution (use Conv 2D transpose). This is the operator designed to grow spatial size, going 4 by 4 up to 8 by 8, then onward to 64 by 64.

How does one layer double the grid? A transposed convolution spreads each input cell over a wider patch before combining, which grows the output side. With kernel size , stride , and padding , the output side length is . Check it on the first upsample: — exactly the in the table. Run the same arithmetic on 8 and you get 16, then 32, then 64. The doubling in the table is this formula applied four times.

Q: Where did transposed convolutions already appear in the convolutional autoencoder assignment, and why were they needed?

A: In the decoder. The encoder compressed a large original image down to a small latent code, and the decoder had to grow that encoded code back toward image size while the reconstruction error was minimized. Ordinary convolutions shrink or preserve spatial size, so growing fell to the transpose convolution. The DCGAN generator faces the identical job — starting from a small vector and creating image-shaped data — so it uses the same operator in place of a decoder.

Once training finishes, throw the discriminator away. Generating data is now just rolling the random vector again and again and passing each roll through the generator module. Sampling is cheap, entirely neural-network based, and fast — change the 100 numbers, get a brand-new image.

11.5.2 Discriminator Design and Training Rules

In principle the discriminator could be any standard CNN classifier doing two-class discrimination: real versus generated. In practice, vanilla choices fail under the adversarial loss, so the DCGAN recipe applies engineering modifications. These are optimized settings, and the system is famously very sensitive: change the architecture carelessly and training breaks. Obey the recipe and reasonable training follows for many datasets of smallish images.

Scope: Treat these five rules as load-bearing. Each exists because its vanilla alternative broke adversarial training:

  1. No max pooling and no mean pooling layers anywhere. Resizing is done by strides alone. The generator upsamples with transposed convolutions; the discriminator downsamples with strided convolutions. Pooling layers discard spatial information too bluntly for the adversarial signal to survive.
  2. Activations: ReLU inside the generator; Leaky ReLU with negative slope 0.2 inside the discriminator. Leaky ReLU passes a small fixed fraction (0.2 times the input) when the input is negative instead of zeroing negatives out — dead units are far more damaging to a judge that must keep grading fakes than to an ordinary classifier.
  3. Output nonlinearities: tanh for the generator's final layer (mapping pixel values into the fixed range); sigmoid for the discriminator's final realness probability.
  4. Batch normalization in both networks, applied everywhere except the output layer of the generator and the input layer of the discriminator. Batch norm keeps layer inputs stationary during training and, together with minibatch-aware features, helps prevent mode collapse. The excluded layers are exactly where the raw signal enters and leaves each network — normalizing there would squash what the other player needs to see.
  5. Optimizer settings: Adam with a small learning rate of 0.0002 and a momentum term of 0.5 — well below usual defaults, because oversized steps let either player sprint ahead of the other. Batch sizes around 64 to 128 are typical for recipes of this family; the WGAN loop later in this lecture uses 64.

Good samples have been produced this way on datasets containing around 3 million images, provided the images stay small.

11.5.3 Results: Faces and Interpolations

Trained on face collections, the generator produces convincing synthetic humans purely by varying the input noise vector. Look at the variety: different skin tones, different genders, people wearing glasses and people without, varying ages, lots of hair and bald heads, young faces and older ones. Every portrait is fabricated; none corresponds to a photographed person.

The model also behaves well in high-dimensional space: interpolations come out smooth. Feed two views of the same scene — two viewpoints of one environment — and the network can synthesize intermediate views, nice-looking images that were never captured. That interpolation ability doubles as evidence that the generator learned a structured representation, not a lookup table: between any two learned points there is a sensible path, which only happens when nearby latent codes map to visually nearby outputs.

Limits repeat from before: chase larger images while keeping clarity and performance decays.

11.5.4 Vector Arithmetic on Latent Semantics

The most beautiful DCGAN discovery: the latent space supports vector arithmetic. Pass many random vectors through the generator, collect the outputs, and visually group them by attribute — say three smiling women generated from , alongside neutral women and neutral men.

Worked example (the smiling-vector recipe).

Step 1 — average within the class: . Decoding gives a smiling woman whose face blends the three inputs — interpolation inside the class.

Step 2 — isolate the attribute direction: where the overline marks the class average. This difference captures smiliness alone, because everything the two averages share (identity, lighting, background) cancels in the subtraction.

Step 3 — transfer the attribute: pick a neutral man's vector and decode which yields a smiling man. Final answer: adding the smile direction moves his expression while leaving identity untouched. In short, averaging within a class interpolates inside it, subtracting two class averages isolates one attribute as a direction, and adding that direction transfers it onto another identity. Sense-check: if the direction were meaningless noise, decoding would corrupt the whole face rather than change one attribute — the clean result confirms the semantics are linearly addressable.

The glasses trick repeats the pattern: subtract men-without-glasses vectors from men-with-glasses vectors to isolate "glassesness," then add that direction to a woman's vector and get a woman wearing glasses.

You are playing with the semantics of the data inside the input vector of the generator. Attributes became addressable coordinates.

Real-world connection: many photo editing applications improved significantly thanks to exactly this kind of manipulation, and these synthesized faces double as fake-but-realistic training or display imagery. The same idea — find a direction in a learned latent space that encodes one human-meaningful factor — now powers editable generative tools far beyond faces.

11.5.5 Strengths, Limits, Takeaways

Summary judgment on DCGAN. Incredible samples for a generative model of its era, especially given that sampling costs one forward pass. Not so good for very large images. Works well when the specific architectural details above are respected; without those specifics, expect trouble. Interpolation and representation learning come free. The open problems: unstable training, brittle architecture hyperparameters — an awful lot of tweaking. Those two problems motivate the principled fixes coming next.

DCGAN proved convolutional GANs can synthesize convincing small images — if you follow the recipe exactly. Its brittleness is the lesson: a formulation whose results hinge on optimizer quirks is asking for a better foundation, which Sections 11.7–11.9 build.

11.6 Improved Techniques for Better GAN Training

One influential paper collected a toolbox of generic stabilization recipes for GAN training. Later work moved past parts of it, but the paper mattered enormously, and the recipes apply generally whenever GAN training misbehaves. One idea each, briefly.

11.6.1 Feature Matching

The discriminator is a stack of layers, and its intermediate layers already extract features from whatever passes through. Feature matching exploits them. Compute the average feature vector of real training data at some intermediate layer. Compute the average feature vector of generated data at the same layer. Then minimize the distance between the two averages, in addition to the usual adversarial objective:

Here denotes the feature vector taken from one intermediate discriminator layer, ranges over real data from , over generated data, and is the squared Euclidean norm of the difference between the two averages.

If generated images truly resemble training images, their internal features should match too, not just their surface success at fooling the judge. This added pressure often stabilizes training, because it gives the generator a target that stays informative even when the discriminator itself becomes easy to fool.

11.6.2 Minibatch Discrimination

Mode collapse is the enemy here. Real batches vary richly; collapsed generated batches do not. So give the discriminator a side channel. For each sample, compute a similarity summary against the other members of its batch — call it , a vector describing how sample relates to its batchmates. Feed the discriminator both the usual CNN features and this similarity vector. A healthy batch shows a spread of moderate similarities; a collapsed generated batch is abnormally self-similar, and that deviation from healthy batch statistics is exactly what the discriminator sees through . The generator then gets penalized for producing batches that all look alike. Net effect: a detector aimed squarely at mode collapse.

The textbook framing says the same thing in one line: minibatch discrimination lets the discriminator send a signal encouraging the generator to include a similar amount of variation as the original dataset.

11.6.3 Historical Averaging

Training also benefits if parameters refuse to wander wildly. Historical averaging adds a penalty keeping the current parameter vector close to the running average of all previous parameter vectors:

is the full parameter vector after update , counts updates so far, and the fraction makes the second term their running mean.

The new theta should not stray far from the average of every theta observed in earlier iterations. This damps the oscillation typical of minimax games: if the two players keep trading positions back and forth around an equilibrium, the average barely moves, so any wild swing pays a penalty.

11.6.4 One-Sided Label Smoothing

When computing cross-entropy, do not demand that real data produce exactly 1 at the discriminator. Use 0.9 instead for real samples only — one-sided smoothing. Why? A discriminator pushed toward extreme confidence on reals becomes overtrained, and an overconfident judge hands the generator useless gradients. Softening the target keeps the judge humble and trains the generator better.

A tiny numeric picture of the effect: suppose the discriminator currently outputs 0.99 on a real image. With target 1.0 its cross-entropy is nats — almost no learning signal remains, and the judge keeps sharpening toward saturation. With smoothed target 0.9 the loss becomes nats, a healthy gradient that keeps the judge's slope alive. Only the real label is softened ("one-sided"); fake targets stay at 0, because softening those would encourage the discriminator to tolerate obvious fakes.

11.6.5 Virtual Batch Normalization

Ordinary batch normalization normalizes using the current mini-batch, letting samples within a batch co-adapt. Virtual batch normalization changes the reference point: fix one reference batch of 128 real images, sampled once from the training set and kept aside. Normalize each new example using statistics computed over that example plus the reference batch. Layer inputs stay stationary across steps without within-batch co-adaptation — helpful mainly in the generator. The trade-off is speed: every forward pass now drags 128 extra images along for the statistics, so it is reserved for situations where co-adaptation actively hurts.

11.6.6 Semi-Supervised GAN

If labels exist for some training points, use them. Widen the discriminator's output from binary real-or-fake to outputs: the first correspond to the known classes, the extra one to "fake." The loss splits:

where is the standard GAN loss and maximizes the probability of correct classification whenever a labeled real sample arrives — that is, whenever its class index satisfies , so the sample belongs to one of the known classes rather than to the "fake" slot .

The requirement is access to at least some labeled training data. The payoff runs both ways: the classifier learns from unlabeled data through the GAN signal, and the generator receives richer feedback because the judge now understands class structure.

11.6.7 Projected GANs and Pre-Trained Feature Spaces

Modern twist: run the adversarial comparison not on raw pixels but inside a pre-trained network's feature space. Suppose denotes frozen layers of a pre-trained backbone — think Inception V3, or ResNet variants. Project both real images and generated images through those layers. Then apply the GAN principle to the projections: discriminators operate on the frozen features at multiple scales, and their adversarial losses are combined into one objective summed over the available layers . Payoffs: improved image quality and reduced training time, because the heavy lifting of representation learning is borrowed rather than relearned.

This idea rides a broader truth of modern deep learning: rarely do you have the data or the compute budget to start from scratch. Pre-trained models exist in abundance, and using one adapted to your task beats building fresh — pre-training and transfer learning are the practical workhorses of industrial deep learning.

Caveat: backbone choice matters. Not every pre-trained network serves equally well. In one comparison discussed, a ResNet variant delivered quite low FID scores with a moderate parameter count and competitive top-one accuracy, while other choices traded those axes differently. Treat the backbone as a hyperparameter you must evaluate, not a free lunch.

Real-world connection: projected-GAN thinking is the same muscle as industry transfer learning — freeze a strong backbone, train only what your task adds.

None of these seven tricks changes the game itself; they steady the players — matching internal features, exposing batch uniformity, damping parameter swings, humbling the judge, decoupling batch statistics, exploiting labels, and borrowing frozen representations. When a GAN misbehaves, reach for this shelf before rewriting the objective.

11.7 Distances Between Data Manifolds

11.7.1 The Data Manifold Picture

Before picking a distance, agree on what "close" should mean. Training a generator is not matching single points — it is sliding one whole cloud of points onto another.

Simplify to two dimensions to see the geometry. Plot the training data after projecting it down — or grab any two dimensions and scatter the points. The cloud of points traces a data manifold: the low-dimensional surface on which real data concentrates. A manifold, in this context, means exactly that — a curved lower-dimensional sheet inside the high-dimensional pixel space, the way a sheet of paper crumpled in your fist is still a 2D surface living in 3D space. Now overlay the generator's outputs, sampled across many noise inputs. They form a second cloud. Training a generator means closing the gap between the two clouds — pulling every generated point closer to the manifold of real data. A distance function is precisely the measuring stick that defines "closer" and drives that movement.

Visual intuition: horizontal plane = the two projected dimensions; height (or shading) = density. The real data forms one shaded ridge; generated samples form a second ridge somewhere else on the plain. Early in training the ridges barely touch; each step of good training bends and slides the generated ridge toward the real one. Remember the caveat: the real fight happens in a huge space whose dimensionality is pixels times channels; the sketch is a cartoon of that high-dimensional reality.

11.7.2 JS Divergence: Symmetric but Saturating

Name the two parties: , the real data distribution, and , the generator's distribution. The goal is a distance whose reduction drags the generated cloud onto the real one. Start from KL's shortcomings. KL is asymmetric: traveling from to is not the same journey as returning. The Jensen–Shannon divergence fixes the asymmetry by averaging two KL terms against the midpoint :

The midpoint distribution simply puts half of each distribution's mass at every location; both players are then measured against this average.

Its behavior: JSD equals zero exactly when the two distributions coincide, rises while they partially overlap, and then saturates at once their supports stop overlapping entirely. Why ? Fill in the algebra for the fully disjoint case. Where only has mass, contributes nothing to the midpoint, so there ; likewise on 's own support. Then:

and identically . Half of each term sums back to . That saturation is fatal for GAN training. Two disjoint distributions separated by a mile and two disjoint distributions separated by a continent both report . The number carries no gradient information about how far apart things are.

And early training is precisely the disjoint regime. The generator starts terrible, so its distribution sits far from the data. The judge learns quickly while the generator lags — and JSD sits pinned at its ceiling, whispering nothing. Only in the narrow range where the distributions overlap does JSD behave usefully. Worse, at the moment of first contact the value jumps discontinuously from to smaller values, a kink that makes optimization awkward. Picture the curve: distance between clouds along the horizontal axis, JSD value rising vertically — flat ceiling plateau, then a cliff down at first overlap. A better yardstick is needed.

Pitfalls:

  • Reading a flat JS-based loss as "no progress possible." It means the supports do not yet touch; progress information was lost, not work.
  • Expecting symmetry to fix everything. JSD repaired KL's asymmetry but kept the saturation defect, which matters more for training dynamics.
  • Trusting gradients near first contact: the discontinuity at overlap makes steps erratic exactly when learning should accelerate.

Real-world placement: this analysis is why practitioners watch sample quality stall early in vanilla GAN training. The objective stopped giving directions while the generator was still hopeless — the failure mode Section 11.8 is built to remove.

JS divergence is symmetric but saturates: once supports stop overlapping it reports a constant regardless of how far apart the distributions are, so it cannot guide early GAN training. The next section introduces the distance that keeps giving useful readings at any separation.

11.8 The Wasserstein Distance

11.8.1 Earth Mover Intuition

What if a distance could tell you how far apart two distributions are, even when they share no points at all? Picture moving dirt instead of comparing curves.

Enter the Wasserstein distance, also called the Earth Mover's distance. The lecture's picture: two piles of sand with different shapes. Your job: move sand from one pile until it exactly resembles the other. The Earth Mover's distance is the energy spent in that reshaping — equivalently, the minimum amount of sand that must be lifted and carried to turn one pile into the other. Small effort means the piles were similar to begin with; huge effort means they were far apart. The metaphor scales down beautifully to probability distributions, which are just piles of unit volume split across locations.

Where the analogy maps cleanly: sand = probability mass, positions = values of , carrying work = mass times distance moved, and "the cheapest overall moving plan" = the minimization in the formula below. Where it breaks: real sand can be dumped anywhere, while a transport plan must respect exact column-by-column bookkeeping — every unit taken from somewhere must land somewhere specific.

11.8.2 Shovel-by-Shovel Worked Example

Make the piles discrete. Draw histograms where each block is one shovel-load of sand, laid out over five adjacent columns. Pile one has column heights ; pile two has . Both piles contain the same total volume — eight shovels — matching the rule that probabilities sum to one.

Worked example (finding the cheapest moving plan).

Step 1 — read the mismatches column by column (pile one minus pile two):

Negative entries need sand delivered; positive entries have sand to spare.

Step 2 — design a plan that fixes every mismatch with short hauls:

  • Move 2 shovel-loads from column two into the deficit at column one.
  • Move 2 shovel-loads from column four into the deficit at column three.
  • Move the remaining 1 shovel-load from column four into the deficit at column five.

Every haul crosses exactly one column boundary, so the tally comes to five shovel-moves of transported sand in total: .

Step 3 — confirm this is the best plan. A quick certificate: walk left to right and track how much mass has crossed each boundary so far — the running difference between the piles' cumulative sums is , and any legal plan must pay at least the sum of these crossings, which is 5. Our plan achieves exactly 5, so it is optimal. Alternative plans (for instance, dragging column four's spare shovels across to column one, three boundaries each) transform the same piles but cost strictly more.

Sense-check: both piles keep eight shovels throughout — nothing was created or destroyed, only relocated, exactly as conservation of probability demands.

Many plans other than the optimal one also transform pile one into pile two — route different shovels along different boundaries and the piles still match at the end — but those plans cost more. The Wasserstein distance is defined by the best plan: the minimum-cost way to reshape one distribution into the other.

Note the constraint that makes this a probability tool rather than a general one: both piles must hold equal total volume, which for distributions means both sum to one.

11.8.3 Formal Definition Through Optimal Transport

Write it mathematically. Let be the family of joint distributions whose marginals are and — the Cartesian product coupling of the two laws. Each is one transportation plan specifying how much mass travels from point to point .

The expectation averages the travel distance (the standard choice is the Euclidean norm) over all mass shipments under plan ; the infimum keeps the smallest such average over every admissible plan. The marginal constraints say: the mass leaving each real-data location totals 's density there, and the mass arriving at each destination totals 's density there.

Why not just compute this directly? Count the work. Ten support points on one side and ten on the other means reasoning over pairings of size order , about 100 pairs. And every one of exponentially many plans must be evaluated to certify the infimum. With continuous, high-dimensional distributions the enumeration explodes. Evaluating the Wasserstein distance exactly is an optimal transport problem, and it is intractable head-on — solvable in principle as a linear program (minimize the shipping cost subject to the supply-and-demand constraints), but that remains expensive at scale. Nothing comes free in machine learning: an honest, well-behaved distance turns out to be expensive to compute exactly. The blog article recommended alongside this topic develops the concept further, discrete and continuous alike, and is well worth the read.

11.8.4 Non-Overlap Stress Test

Line the contenders up on the worst case. Let be a lump concentrated at the origin and the identical lump shifted rightward by , so the two fail to touch for any .

Measure Value when disjoint Value at
0
0
, flat in 0
0

Read the rows. KL explodes to infinity the instant the supports separate — the lump sits where the shifted lump assigns zero density — and infinities are miserable to optimize. JS freezes at regardless of separation: useless exactly when guidance matters most, and nondifferentiable at contact, jumping between 0 and . The Wasserstein distance returns — literally the distance the lump traveled. At zero shift everything agrees at zero; as shift grows, only W keeps growing sensibly, always proportional to the actual gap. Quick sanity checks: every row is non-negative as a distance must be; shrinking continuously shrinks only W smoothly to zero; and W is symmetric under swapping the two lumps, matching . So minimizing W drags the generator toward the data from any starting distance, which is exactly the property a GAN loss needs. That smooth, informative behavior is the goodness of the earth mover's distance.

Real-world placement: optimal transport now reaches beyond GANs — color transfer between images compares pixel distributions by earth-mover cost, and document retrieval systems embed histograms of words and rank them by transport distance.

The Wasserstein distance is the cheapest reshaping cost between two distributions: informative even for disjoint supports, proportional to actual separation, and symmetric — everything JS and KL fail at in the regime where GAN training begins.

11.9 WGAN: Wasserstein Generative Adversarial Network

11.9.1 Kantorovich-Rubinstein Duality and Lipschitz Functions

Direct evaluation of W is intractable, but a certain duality rescues it: the Kantorovich-Rubinstein duality. Its derivation belongs to real analysis, not to this course — consult a real analysis text for the proof — but the statement is compact. The infimum over transport plans can be rewritten as a supremum over functions:

The notation means: search over all functions whose Lipschitz constant is at most one, and take the largest achievable difference.

Plain words: sample from the real distribution and evaluate some function ; sample from the generated distribution and evaluate the same . Take the difference of the two averages. Search over the allowed class of functions for the one making this difference largest. That largest difference equals the Wasserstein distance.

Why should such a duality hold? A one-line intuition: a gentle function cannot spike up only where reals live and dive only where fakes live unless mass genuinely had to be carried between them — the smoothest possible "price tag" landscape over space encodes exactly how much hauling separates the two piles. The proof makes this rigorous; using the statement needs no real analysis.

The allowed class is the 1-Lipschitz functions. A function is K-Lipschitz continuous if there exists a real constant such that for every pair of points:

Equivalently, in the continuous limit, the absolute slope never exceeds : .

Setting gives the 1-Lipschitz family: functions whose steepness nowhere exceeds one. Two quick membership checks: fails (slope 2 everywhere), while passes, since its slope never tops 1; and fails outright because its slope grows without bound. Crucially this is not one function but a vast class — the optimization searches within that class for the right member, and the search happens by adjusting neural network weights.

11.9.2 The WGAN Objective and the Critic

Install the dual form directly into the GAN template. The generator minimizes, the function maximizes, and the function must stay 1-Lipschitz:

Compare with the original formulation's tangle of and terms — this objective is much simpler. Terminology shifts too: is no longer called the discriminator but the critic. The rename is earned. A discriminator answers a two-value question — real or fake — squeezing everything into probabilities between 0 and 1. A critic scores how different two distributions are, on an unbounded scale: high output when things differ, low when they match. The critic must be learned — among all 1-Lipschitz functions, pick whichever maximizes the gap, shaping it by updating weights.

11.9.3 Enforcing the Constraint: Weight Clipping and Training Pseudocode

How do you force a neural network to respect the Lipschitz bound? The original answer is blunt: weight clipping. Constrain all critic weights to live in a compact interval around zero, with a small constant. After every update, squash any weight outside the box back onto its edge. Clipped weights cannot have arbitrarily steep input-output slopes, which keeps the critic inside the Lipschitz class.

The full training loop, with symbols named. Let be the learning rate. Let be the clipping constant. Let be the batch size and the number of critic iterations per generator iteration. Let denote the initial critic parameters and the initial generator parameters.

  1. While has not converged:
  2. For to :
  3. Sample a batch of 64 real points from the training data.
  4. Sample a batch of 64 noise vectors from the prior.
  5. Estimate the critic's ascent gradient:

This is exactly the dual expression: average critic output on reals minus average critic output on generated samples, differentiated with respect to the critic weights.

  1. Update the critic by following RMSProp — the optimizer introduced back in the deep-neural-networks course, root-mean-square propagation — then clip every weight into .
  2. After the five critic rounds, sample a fresh batch of noise vectors and update the generator once, ascending the critic's score of the generated samples.

Trace of the critic score (one round, shrunk to four samples for readability). Suppose the current critic assigns the four real images scores and the four generated images scores .

Step 1 — average over reals: .

Step 2 — average over generated: .

Step 3 — the bracket evaluates to : the current Wasserstein estimate. The gradient ascent step then nudges every weight so that this gap widens — pushing real scores up and fake scores down — after which any weight outside is clipped back onto an edge. The generator's later update reads the same number from the other side: it reshapes to shrink the gap. Sense-check: as long as the critic stays smooth, 0.55 behaves like a distance reading — it falls toward zero when the two clouds merge.

Much of this mirrors the original GAN pseudocode — alternate players, train the judge more often than the builder — but the objective is different, and so is the optimizer choice. Note the asymmetry by design: several critic steps per single generator step, because the critic must stay near its own optimum for its score to mean "distance."

Complexity and cost: each generator step costs five critic steps plus clipping, so WGAN training runs roughly five times the critic compute of a vanilla GAN step-for-step; the payoff is that far fewer total steps are needed before samples look reasonable.

When to use / alternatives: use the WGAN objective when vanilla GAN training oscillates or collapses; alternatives are the improved-techniques toolbox of Section 11.6 or the gradient penalty below, which replaces clipping entirely.

11.9.4 Why WGAN Trains Better

Three empirical behaviors justify the machinery.

First, gradients survive bad starts. Watch the critic's values as training begins, when the generated distribution sits far from the real one. The critic's output still separates cleanly and its curve changes smoothly with distance, so the generator receives a strong, meaningful gradient signal even in the worst regime. Contrast the standard GAN: a confident discriminator saturates, outputting near-zero on fakes everywhere, so differentiating its loss yields vanishing gradients for the fake samples precisely when the generator most needs direction. The critic replaces collapse with proportionality.

Second, the distance tracks quality. With the Wasserstein estimate in use, as the perceptual quality of generated data climbs, the measured Wasserstein distance falls. That correlation fails under JSD, whose plot stays flat and only occasionally dips without any link to visible quality. Distance here is correlated with sample quality — a diagnostic you can actually read. Side-by-side sample grids made the case visibly: early WGAN output already showed clarity that the baseline never reached.

Third, stability under architecture edits. Tiny architectural tweaks to a DCGAN flip how results come out — drop batch normalization and the outcome jumps completely. WGAN degrades gracefully under the same perturbations; it is insensitive to architectural choices in a way DCGAN never was.

11.9.5 Open Problems: Clipping Side Effects and What Comes Next

Nothing is free here either. Weight clipping enforces Lipschitz-ness crudely: once training settles, weights pile up at the rails and , almost none resting between them. The capacity of the weight range goes unleveraged — the network cannot express fine distinctions when every weight is pinned at an extreme.

And the clip constant is a tightrope. WGAN proves sensitive to the clipping budget: choose very small and gradients vanish — the critic grows feeble; choose relatively large, something like 0.1, and gradients explode instead. Tuning one constant decides between two failure modes.

The announced remedy is the gradient penalty. Instead of clipping, take the gradient of the critic function itself and penalize its magnitude directly, nudging the critic toward slope one without crushing weights onto rails. That improvement opens the next meeting, which continues through WGAN variants and the wider GAN architecture tour — conditional GAN, CycleGAN, and StyleGAN among the popular designs. After that, the course advances to diffusion models and energy-based models for data generation.

Real-world placement: WGAN's readable loss became a monitoring standard — teams plot the critic score during training the way others plot validation accuracy, because unlike most generative losses it moves when quality moves.

Exam note: expect conceptual questions contrasting mode collapse with mode covering, explaining why JS divergence saturates, and stating what the critic measures. The finals-preparation webinar will drill problems of this kind, so start revising the GAN material now rather than waiting for the pre-exam window. An upcoming assignment covering VAEs and GANs spans several weeks; begin immediately and divide the work across your team, or the deadline pressure will bite.

UDL Lecture 11 notes · Improving GAN Training: Optimal Discriminators, DCGAN, and the Wasserstein Distance

Unsupervised Deep Learning· postgraduate· 2026-08-25

Sections Breakdown

111.1 Where GANs Stand Among Generative Models

GANs are the one implicit generative model: no density is ever written down, two networks play a minimax game instead, so quality must be judged with IS and FID rather than a likelihood.

211.2 What Makes a GAN Fast — and Where It Struggles

GAN sampling is a single generator forward pass, which makes it faster than any iterative likelihood-based sampler, but the price is weak RGB quality past 64x64, no sample-level likelihood, and unstable minimax training.

311.3 Theory of the Optimal Discriminator

Maximizing the discriminator's value functional pointwise yields D*(x) = p_data/(p_data+p_g), a density ratio; substituting it back shows the generator's cost floor is -log4 + 2*JSD(p_data, p_g).

411.4 Comparing Distributions: Forward KL, Reverse KL, Mode Collapse, Mode Covering

On a two-bump mixture toy problem, forward KL forces the fit to cover every mode (mode covering, implausible valley samples) while reverse KL hugs one mode (mode collapse, sharp but repetitive samples); JSD averages both pressures.

511.5 DCGAN: Deep Convolutional GAN

DCGAN grows a 100-dim noise vector through a projection to 4x4x1024 and four transposed convolutions into 64x64x3 images, with a strict recipe (strides not pooling, LeakyReLU, batch norm, Adam lr=0.0002/beta1=0.5); its latent space supports attribute vector arithmetic.

611.6 Improved Techniques for Better GAN Training

A toolbox of seven stabilization recipes: feature matching, minibatch discrimination, historical averaging, one-sided label smoothing (0.9 targets), virtual batch normalization with a fixed 128-image reference batch, semi-supervised k+1 outputs, and projected GANs on frozen pre-trained features.

711.7 Distances Between Data Manifolds

Training a generator means pulling the generated sample cloud onto the real data manifold; JSD measures that gap symmetrically but saturates at log2 for disjoint supports, giving no gradient exactly when guidance matters most.

811.8 The Wasserstein Distance

The Wasserstein (Earth Mover's) distance is the minimum work needed to reshape one distribution into the other - an infimum over transport plans of expected travel distance; unlike KL/JSD it stays finite and proportional to separation even for disjoint supports.

911.9 WGAN: Wasserstein Generative Adversarial Network

WGAN replaces the JS-based minimax with the Kantorovich-Rubinstein dual of the Wasserstein distance - a 1-Lipschitz critic maximizes the real-vs-fake score gap, trained five rounds per generator step with RMSProp and weight clipping into [-c, c].

Postgraduate students in machine learning and deep learning

Exam Revision Notes

Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.

Where GANs Stand Among Generative Models

Must-know: AR/flows give explicit exact densities, VAEs an approximate bound, GANs none at all - implicit sampling via a generator-discriminator minimax game.

⚠️ Top pitfall: Expecting a GAN to output a likelihood for a sample; it cannot - that is why IS and FID exist.

Self-check: Why does a high Inception Score alone not guarantee good images? (It can miss perceptual quality; pair it with FID.)

Connects to: What Makes a GAN Fast — and Where It Struggles; Distances Between Data Manifolds

What Makes a GAN Fast - and Where It Struggles

Must-know: One forward pass = fast sampling; the costs are poor large-RGB-image quality (drops past ~64x64), no likelihood for individual samples, and minimax instability.

⚠️ Top pitfall: Forgetting that 'fast sampling' refers only to generation after training; the training loop itself is slow and brittle.

Self-check: Why can't you score how plausible one GAN sample is? (No density is ever learned - implicit modeling.)

Connects to: Where GANs Stand Among Generative Models; DCGAN: Deep Convolutional GAN; WGAN: Wasserstein Generative Adversarial Network

Theory of the Optimal Discriminator

Must-know: Optimal discriminator is the density ratio p_data/(p_data+p_g); generator loss at optimum is C(G) = 2*JSD - log4 with floor -log4 (about -1.386 nats) reached iff p_g = p_data.

⚠️ Top pitfall: Quoting the floor as 'minus log zero' or forgetting that D* = 1/2 everywhere when the generator is perfect.

Self-check: At a point where p_data = 0.6 and p_g = 0.2, what is D*? (0.75 - called real.)

Connects to: Comparing Distributions: Forward KL, Reverse KL, Mode Collapse, Mode Covering; Distances Between Data Manifolds

Comparing Distributions: Forward KL, Reverse KL, Mode Collapse, Mode Covering

Must-know: Forward KL -> mode covering (variety kept, quality lost); reverse KL -> mode collapse (quality kept, variety lost); JSD averages both; peak position of a mixture encodes mixture weights, not component means.

⚠️ Top pitfall: Swapping the KL argument order in your head - the first argument does the weighting and decides which failure mode appears.

Self-check: Why does a collapsed fit q=(1,0) get infinite penalty under forward KL against p=(0.5,0.5)? (log(0.5/0) explodes.)

Connects to: Theory of the Optimal Discriminator; Distances Between Data Manifolds; WGAN: Wasserstein Generative Adversarial Network

DCGAN: Deep Convolutional GAN

Must-know: DCGAN shape walk 100 -> 4x4x1024 -> 8x8x512 -> 16x16x256 -> 32x32x128 -> 64x64x3 via fractionally strided convolutions; recipe: no pooling (strides only), ReLU/tanh generator, LeakyReLU(0.2)/sigmoid discriminator, batch norm except G-output and D-input, Adam lr=0.0002 momentum 0.5; discard the discriminator after training.

⚠️ Top pitfall: Treating the architecture rules as optional tweaks - tiny deviations flip training outcomes entirely.

Self-check: Why does the channel count halve while spatial size doubles at every upsample? (Trade spatial resolution against feature depth as the image forms.)

Connects to: What Makes a GAN Fast — and Where It Struggles; Improved Techniques for Better GAN Training; WGAN: Wasserstein Generative Adversarial Network

Improved Techniques for Better GAN Training

Must-know: Know what each of the seven recipes targets: feature matching = match intermediate-layer averages; minibatch discrimination = expose collapsed batches; label smoothing = real target 0.9 only; virtual batch norm = fixed reference batch of 128; semi-supervised GAN = k+1 outputs; projected GANs = adversarial loss in frozen backbone features.

⚠️ Top pitfall: Smoothing both labels; smoothing fakes would teach the discriminator to tolerate obvious fakes. Only reals get 0.9.

Self-check: Which recipe directly attacks mode collapse by comparing each sample to its batchmates? (Minibatch discrimination.)

Connects to: DCGAN: Deep Convolutional GAN; WGAN: Wasserstein Generative Adversarial Network

Distances Between Data Manifolds

Must-know: JSD(P||Q) = 1/2 KL(P||(P+Q)/2) + 1/2 KL(Q||(P+Q)/2); it equals 0 iff P=Q and saturates at log2 for disjoint supports - flat, uninformative, with a jump at first contact.

⚠️ Top pitfall: Assuming a flat JS loss means nothing can improve; it means the supports are disjoint so the value is pinned at log2.

Self-check: Why does JSD equal log2 for any two fully disjoint distributions? (On each support M = P/2, so each KL term is exactly log2.)

Connects to: Comparing Distributions: Forward KL, Reverse KL, Mode Collapse, Mode Covering; The Wasserstein Distance

The Wasserstein Distance

Must-know: W = inf over joint couplings gamma with marginals p_r, p_g of E[||x-y||]; for disjoint delta-lumps shifted by theta: KL = inf, JSD = log2 flat, W = |theta|.

⚠️ Top pitfall: Forgetting the equal-total-volume constraint: both distributions must sum to one, which is what makes the transport plan a probability tool.

Self-check: In the five-column shovel example, why must any plan cost at least 5? (The cumulative-sum crossings force that much mass across boundaries.)

Connects to: Distances Between Data Manifolds; WGAN: Wasserstein Generative Adversarial Network

WGAN: Wasserstein Generative Adversarial Network

Must-know: KR duality: W = sup over 1-Lipschitz f of E_r[f] - E_g[f]; WGAN objective min_G max_{Lipschitz D} E[D(x)] - E[D(G(z))]; loop = 5 critic steps (RMSProp + clip to [-c,c]) per generator step; clipping piles weights at rails and c too small starves gradients while ~0.1 explodes them.

⚠️ Top pitfall: Calling the WGAN judge a discriminator that outputs probabilities; it is a critic on an unbounded scale measuring distribution distance.

Self-check: Why train the critic several steps per generator step? (Its score only reads as a distance when it is near its own optimum.)

Connects to: Comparing Distributions: Forward KL, Reverse KL, Mode Collapse, Mode Covering; Distances Between Data Manifolds; The Wasserstein Distance

Was this lecture useful?

Loading comments…
🤖

BitsNotes AI Assistant

Subject Notes Assistant

Configure AI Chat

Choose how to access the chatbot
Have your own API key?

Switch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.

🔑 Enter API key above to fetch live models from provider, or enter model name manually.
OpenAI-Compatible API Support

Choose any provider preset (Gemini, DeepSeek, Kimi, GLM, MiniMax, Qwen, OpenAI, Groq, Ollama, etc.) or enter a custom endpoint URL.

Security & Privacy First

Your API key is sent directly from your browser to your specified provider. BitsNotes servers never store or see your key.