Foundations to Frontier
Tests
H. Generative Models › H1 Foundations

Likelihood-based vs implicit models

Generative models split by what they let you compute. Likelihood-based models define a density p_θ(x) that you can evaluate, or bound, and train by maximum likelihood. Autoregressive models and normalizing flows give it exactly; VAEs and diffusion models give a lower bound. Implicit models only define a sampler x = G(z). GANs and moment-matching networks are trained by comparing samples with data, so they have no likelihood to report. This page lays out the taxonomy (Goodfellow, 2016), what each family can and cannot do, and why forward KL (maximum likelihood) covers modes while sample-based objectives can drop them. It also covers why likelihood and sample quality need not agree (Theis et al., 2016). In the exercises you compute exact and Parzen-window likelihoods and an MMD distance. You then fit an 8-mode ring with a Gaussian mixture by EM and with an implicit generator trained by MMD. The mixture's exact test log-likelihood was −1.138 nats against the true density's −1.120. Its Parzen estimate was −1.208, and a 'model' that only copied the training set scored −1.200, so Parzen could not tell them apart. The implicit generator covered all 8 modes but put only 61% of its samples on them.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Can the model tell you how likely an image is?

Some generative models are like a forecaster who can give the probability of any weather you name: you can ask how likely a given image is. Others are like a painter who can produce convincing pictures but cannot tell you how typical a particular picture is. The first kind (likelihood-based) is trained to give the real data high probability. The second kind (implicit) is trained only by comparing its samples with real ones. The demo fits one bell curve to two-humped data in the two ways: one spreads over both humps, the other sits on one.

Generative models lab
Data (red) has two modes. Maximum likelihood (forward KL, green) puts one Gaussian over both with σ = 2.57, putting mass between the modes where there is no data. Reverse KL (yellow) locks onto one mode (μ = -2.50, σ = 0.60) and ignores the other, like mode collapse.
Why engineers care

A likelihood lets a flight-data model score every new telemetry frame for anomaly detection; an implicit model can only generate, so it needs a separate detector.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A likelihood-based model can…
  2. 2. A GAN is…
  3. 3. Maximum likelihood tends to…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Explicit, exact likelihood: autoregressive models (PixelCNN, WaveNet, GPT) factor p(x) = Π p(x_i | x_before i); normalizing flows use an invertible map and the change-of-variables formula.
  • Explicit, approximate likelihood: VAEs and diffusion models maximise a lower bound (ELBO); energy-based models define p ∝ exp(−E) with an intractable normaliser and use MCMC or score matching.
  • Implicit: a sampler x = G(z), z ~ N(0, I), with no density; trained with a discriminator (GANs), a kernel distance (MMD, GMMN), or optimal-transport distances.
  • Training signal: likelihood models minimise forward KL(p_data ‖ p_θ), which punishes missing any data (mode covering). Implicit objectives approximate other divergences (Jensen–Shannon, Wasserstein, MMD) and in practice may drop modes (mode collapse).
  • Evaluation: likelihood models report test NLL in bits per dimension. Implicit models need sample-based metrics (FID, precision/recall) or Parzen-window estimates, which are unreliable in high dimensions.
  • Today (2026): diffusion and flow-matching models are trained with likelihood-related objectives but often sampled with ODE solvers; autoregressive transformers give exact likelihoods; GANs survive mainly as fast decoders, adversarial losses in tokenizers and distillation targets.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Normalizing flows obtain p(x) with…
  2. 2. VAEs maximise…
  3. 3. Maximum likelihood minimises…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Scoring likelihood and implicit models

Exercise 1.

  • Exact log-likelihood of a Gaussian mixture.
  • Parzen-window log-likelihood estimated from samples.
  • An unbiased MMD² estimate between two sample sets.

Practice.

  • Report likelihoods per dimension in bits (nats ÷ (D ln 2)) so models of different data sizes compare.
  • Add uniform noise to discrete pixels (dequantisation) before fitting continuous densities.
  • Do not use Parzen-window likelihoods for high-dimensional images; use sample metrics instead.
  • For MMD, use several kernel bandwidths; a single small bandwidth gives vanishing gradients.
  • Check samples and likelihood separately: one can be good while the other is poor.
from sklearn.mixture import GaussianMixture
from sklearn.neighbors import KernelDensity
gmm = GaussianMixture(8).fit(X_train)
print("exact test LL", gmm.score(X_test))                  # likelihood-based
kde = KernelDensity(bandwidth=0.1).fit(generator_samples)  # implicit model: estimate from samples
print("Parzen test LL", kde.score_samples(X_test).mean())
🐍 Exercise 1: exact, estimated and sample-based scores
Compute a mixture log-likelihood, a Parzen-window estimate from samples and an unbiased MMD² between sample sets.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Bits per dimension =
  2. 2. Parzen estimates in high dimensions are…
  3. 3. Multiple MMD bandwidths help because…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Forward vs reverse KL. Maximum likelihood minimises KL(p_data ‖ p_θ) = E_data[log p_data − log p_θ], which is infinite if p_θ is zero where data exist: the fit must cover every mode, even at the cost of mass between modes. Reverse KL(p_θ ‖ p_data) is infinite if p_θ puts mass where there are no data: the fit hides inside one mode. A single Gaussian fitted by maximum likelihood to modes at ±2 with variance 0.25 has variance 4.25.

Implicit objectives. The original GAN minimises the Jensen–Shannon divergence at the optimal discriminator; MMD with a characteristic kernel is zero only if the distributions agree. Both need only samples from p_θ, so G can be any network, but there is no p_θ(x) to evaluate.

Likelihood vs quality (Theis, van den Oord and Bethge, 2016). A model can have excellent log-likelihood and poor samples (a mixture of 1% good model and 99% noise loses at most log 100 ≈ 4.6 nats per image, negligible per pixel), or excellent samples and terrible likelihood (a model that copies training images). Parzen estimates are biased and need exponentially many samples in the dimension.

family density trained by sampling
autoregressive exact max likelihood sequential, slow
flow exact max likelihood one pass
VAE, diffusion lower bound ELBO / denoising one pass / many steps
energy-based unnormalised contrastive divergence, score matching MCMC
GAN, GMMN none discriminator / MMD one pass
📝 Quick check (Level 3)
0/3 answered
  1. 1. Reverse KL tends to…
  2. 2. The ideal-discriminator GAN objective is related to…
  3. 3. Good likelihood guarantees good samples?

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

What does a likelihood buy you, and how do implicit models and Parzen estimates fare without one?

History.

  • I. Goodfellow et al., “Generative adversarial nets” (2014); I. Goodfellow, “NIPS 2016 tutorial: generative adversarial networks” (taxonomy).
  • Y. Li, K. Swersky and R. Zemel, “Generative moment matching networks” (2015); G. K. Dziugaite et al. (2015).
  • L. Theis, A. van den Oord and M. Bethge, “A note on the evaluation of generative models” (2016).
  • S. Mohamed and B. Lakshminarayanan, “Learning in implicit generative models” (2016).

Exercise 2. 2-D ring of 8 Gaussians (radius 2, σ 0.15); 1000 training, 500 validation, 1000 test points.

  • Likelihood-based: an 8-component isotropic Gaussian mixture by EM (farthest-point initialisation), and a single Gaussian.
  • Implicit: a tanh MLP generator (2 → 32 → 2) trained for 250 Adam steps to minimise MMD² with bandwidths 0.1, 0.3, 1.
  • Memoriser: returns training points as its samples.
  • Scores: exact test log-likelihood where available; Parzen estimate from 1000 samples with bandwidth chosen on validation; sample quality = fraction within 3σ of a mode; coverage = modes holding at least 5% of their share.
model exact test LL Parzen test LL quality modes
true density −1.120 – – 8
8-Gaussian mixture −1.138 −1.208 0.993 8
single Gaussian −3.550 −3.595 0.126 8
MMD generator none −2.019 0.613 8
memoriser none −1.200 0.996 8
  • Maximum likelihood with the right family came within 0.02 nats of the true density.
  • Mode covering: the single Gaussian touched every mode but only 13% of its samples landed on one.
  • Parzen bias: for the mixture, Parzen underestimated the exact value by 0.07 nats, and it ranked the memoriser (no generalisation at all) level with the mixture.
  • Implicit model: the MMD generator covered all modes (no collapse here) but its samples were blurrier; it offers no likelihood to check.
  • Seeds 1 and 2: mixture exact −1.160 and −1.148 (true −1.142, −1.130); Parzen mixture −1.226 and −1.205 vs memoriser −1.231 and −1.200; MMD quality 0.636 and 0.682.
  • Caveat: 2-D data are kind to Parzen windows; in image dimensions the bias is far larger.
🐍 Exercise 2 (research): what does a likelihood buy you, and how do implicit models and Parzen estimates fare without one?
Fit a ring of Gaussians with maximum likelihood (EM) and with an MMD-trained implicit generator, and compare exact likelihoods, Parzen estimates, sample quality and mode coverage, including a memoriser.

Likelihood-based and implicit models in AI, robotics and aerospace

  • Anomaly detection: exact likelihoods (flows, autoregressive models) score telemetry or imagery for novelty.
  • Simulation: implicit generators (GANs) give fast synthetic sensor data when only realism matters.
  • Weather and climate: diffusion and flow-matching emulators are evaluated with both likelihood-style and sample-based scores.

References

  1. I. Goodfellow (2016). “NIPS 2016 tutorial: generative adversarial networks.” arXiv.
  2. L. Theis, A. van den Oord and M. Bethge (2016). “A note on the evaluation of generative models.” ICLR.
  3. Y. Li, K. Swersky and R. Zemel (2015). “Generative moment matching networks.” ICML.
  4. S. Mohamed and B. Lakshminarayanan (2016). “Learning in implicit generative models.” arXiv.
  5. A. Gretton et al. (2012). “A kernel two-sample test.” JMLR.