Generative Modeling: Learning Data Distributions

Suppose you have a million photographs of human faces. You want a machine that can produce new, never-seen faces. These faces should be indistinguishable from real ones. No labels tell you "this is a face" versus "this is not". You only have samples. This is the generative modeling problem. Given data x1,…,xnx_1, \dots, x_n drawn from some unknown distribution pdata(x)p_{\text{data}}(x), learn a model. This model must capture that distribution well enough to generate new samples. It should also evaluate how likely new data is, or both. Generative modeling matters because most of the world's data is unlabeled. The ability to model p(x)p(x) underlies image synthesis and speech synthesis. It also underlies drug-molecule design, anomaly detection, data augmentation, compression, and simulation of physical systems. A model that truly understands pdata(x)p_{\text{data}}(x) has implicitly learned the structure of the domain. It learns which pixel patterns look like faces. It learns which amino-acid sequences fold into stable proteins. It learns which sentences are fluent English. This is qualitatively different from Supervised Learning. There, a model only learns a conditional mapping p(y∣x)p(y \mid x). The big picture is a fork in the road. Do you model the density pθ(x)p_\theta(x) explicitly? Then you can write down (or approximate) its formula and compute probabilities. Or do you only build a mechanism that produces samples? This is called an implicit model. It never computes a likelihood. Explicit models split further into two types. Some have tractable likelihoods (autoregressive models, normalizing flows). Others have only an approximate or bounded likelihood (Variational Autoencoders, diffusion models). Implicit models are typified by Generative Adversarial Networks. They sidestep likelihood computation entirely. They are trained via an adversarial game or other sampling-based objective. This article builds the conceptual scaffolding for later topics. It covers precise definitions of explicit vs. implicit density. It covers the likelihood-based training principle. It covers the sampling-based alternative. Every later architecture specializes and extends this scaffolding. This includes VAEs, GANs, normalizing flows, and diffusion models.

Key takeaways
  • Generative models learn pdata(x)p_{\text{data}}(x) from samples, enabling synthesis, density estimation, and anomaly detection.
  • Explicit density models write down pθ(x)p_\theta(x) (exactly or approximately); implicit density models only sample from it.
  • Explicit models split into tractable likelihood (autoregressive, normalizing flows) and approximate likelihood (VAEs, diffusion, via bounds).
  • Maximum likelihood estimation (MLE) is the dominant training principle for explicit models: maximize ∑ilog⁡pθ(xi)\sum_i \log p_\theta(x_i).
  • Sampling-based / adversarial objectives (GANs) train a generator without ever evaluating pθ(x)p_\theta(x), using a discriminator as a learned critic.
  • The choice of paradigm trades off sample quality, likelihood tractability, training stability, and sampling speed.
The core insight

A generative model is any function or process trained so that samples it produces — or probabilities it assigns — match an unknown data distribution, and the central design choice is whether that distribution's density is computed explicitly, approximated, or never computed at all.

The idea

A generative model is a probabilistic model pθ(x)p_\theta(x), parameterized by θ\theta (e.g., neural network weights), trained on samples x1,…,xnpdatax_1, \dots, x_n \overset{\text{iid}}{\sim} p_{\text{data}} so that pθp_\theta approximates pdatap_{\text{data}}. This contrasts with discriminative models, which learn p(y∣x)p(y \mid x) directly and are indifferent to the marginal structure of xx. Generative models can be used for three related but distinct tasks: density estimation (compute or bound pθ(x)p_\theta(x) for a given xx), sampling (draw new x∼pθx \sim p_\theta), and representation learning (extract a low-dimensional code zz that explains xx). The taxonomy in this article rests on one axis: how the model relates to the likelihood function pθ(x)p_\theta(x).

Explicit density, tractable likelihood. The model defines pθ(x)p_\theta(x) via a formula that can be evaluated exactly in closed form (or with a cheap forward pass). Two major families achieve this:

  • Autoregressive models factor the joint distribution using the chain rule of probability,
pθ(x)=∏i=1dpθ(xi∣x1,…,xi−1),p_\theta(x) = \prod_{i=1}^{d} p_\theta(x_i \mid x_1, \dots, x_{i-1}),

and parameterize each conditional with a neural network (e.g., PixelRNN, PixelCNN, GPT-style transformers over tokens). Every factor is a normalized distribution over one variable, so the product is automatically normalized — no partition function to worry about.

  • Normalizing flows transform a simple base density pZ(z)p_Z(z) (e.g., a standard Gaussian) through an invertible, differentiable map x=fθ(z)x = f_\theta(z), and use the change-of-variables formula
pθ(x)=pZ(fθ−1(x))∣det⁡∂fθ−1(x)∂x∣.p_\theta(x) = p_Z(f_\theta^{-1}(x)) \left| \det \frac{\partial f_\theta^{-1}(x)}{\partial x} \right|.

Both families allow exact log-likelihood computation, so training reduces to plain maximum likelihood.

Explicit density, approximate likelihood. The model posits latent variables zz with pθ(x)=∫pθ(x∣z) p(z) dzp_\theta(x) = \int p_\theta(x \mid z)\, p(z)\, dz, but this integral is intractable to compute exactly for expressive decoders pθ(x∣z)p_\theta(x\mid z). Instead of the true likelihood, training maximizes a tractable lower bound on it — the evidence lower bound (ELBO) in Variational Autoencoders, or a denoising-based bound in diffusion models. You never compute pθ(x)p_\theta(x) exactly, only a certified bound on log⁡pθ(x)\log p_\theta(x).

Implicit density. The model provides only a sampling procedure — typically x=Gθ(z)x = G_\theta(z) for z∼p(z)z \sim p(z) a simple noise distribution and GθG_\theta a neural network — with no tractable expression for pθ(x)p_\theta(x) at all. Generative Adversarial Networks are the canonical example: a generator GθG_\theta and discriminator DϕD_\phi are trained jointly so that GθG_\theta's samples become indistinguishable from real data according to DϕD_\phi, an objective that requires no likelihood evaluation whatsoever. The training principle splits along the same lines. Likelihood-based training (MLE or its bound) directly optimizes a probabilistic objective and gives you calibrated density values as a byproduct. Sampling-based / adversarial training optimizes an objective defined purely in terms of samples — often a divergence estimated implicitly through an auxiliary discriminator or a two-sample test — and never yields a usable pθ(x)p_\theta(x).

How it works

Regardless of family, generative model training follows a common template: define a parametric object that can produce or score samples, define a loss connecting model and data, and optimize by gradient descent. Below are the two canonical mechanisms — MLE for explicit models, and adversarial training for implicit ones — laid out as algorithms, followed by a diagram placing all four families on the same map.

Mechanism 1 — Maximum Likelihood Training (explicit density). The population objective is to minimize the Kullback–Leibler divergence from data to model,

θ∗=arg⁡min⁡θDKL(pdata ∥ pθ)=arg⁡max⁡θ Ex∼pdata[log⁡pθ(x)],\theta^* = \arg\min_\theta D_{\mathrm{KL}}(p_{\text{data}} \,\|\, p_\theta) = \arg\max_\theta \, \mathbb{E}_{x \sim p_{\text{data}}}[\log p_\theta(x)],

which is estimated with the empirical average over the training set — this is maximum likelihood estimation. ``` Algorithm: Maximum-Likelihood Training of an Explicit Density Model Input: dataset D = {x_1, ..., x_n}, model p_theta with tractable log p_theta(x) Output: fitted parameters theta 1. Initialize theta randomly 2. repeat until convergence: 3. sample a minibatch B ⊂ D of size m 4. compute batch log-likelihood: L(theta) = (1/m) sum_{x in B} log p_theta(x) 5. compute gradient g = ∇_theta L(theta) # exact if likelihood is tractable 6. theta ← theta + eta g # gradient ASCENT on log-likelihood 7. return theta

# For autoregressive models: log p_theta(x) = sum_i log p_theta(x_i | x_

# in one forward pass with a causal mask (teacher forcing).

# For normalizing flows: log p_theta(x) = log p_Z(f_theta^{-1}(x)) + log|det J_{f_theta^{-1}}(x)|,

# requiring f_theta invertible with a tractable Jacobian determinant.

# For latent-variable models (VAE/diffusion): replace step 4 with a lower bound ELBO(theta, phi) ≤ log p_theta(x),

# introducing an auxiliary inference network with parameters phi, and ascend the bound instead. ```

Mechanism 2 — Adversarial (sampling-based) training (implicit density). ``` Algorithm: Adversarial Training of an Implicit Generative Model Input: dataset D of real samples, noise prior p(z), generator G_theta, discriminator D_phi Output: fitted generator parameters theta 1. Initialize theta, phi randomly 2. repeat until convergence: 3. sample minibatch of real data {x_1,...,x_m} ~ D 4. sample minibatch of noise {z_1,...,z_m} ~ p(z) 5. fake samples: x̂_j = G_theta(z_j) 6. # --- discriminator step: push D toward distinguishing real vs. fake --- 7. phi ← phi + eta_D ∇_phi [ (1/m) sum_i log D_phi(x_i) + (1/m) sum_j log(1 - D_phi(x̂_j)) ] 8. # --- generator step: push G to fool the (updated) discriminator --- 9. re-sample noise, recompute x̂_j = G_theta(z_j) 10. theta ← theta + eta_G ∇_theta [ (1/m) sum_j log D_phi(x̂_j) ] # non-saturating variant 11. return theta

# No log p_theta(x) is ever computed. D_phi acts as a learned, implicit density-ratio estimator:

# at the Nash equilibrium, D*(x) = p_data(x) / (p_data(x) + p_theta(x)), which is exactly 1/2 everywhere

# iff p_theta = p_data, tying the adversarial game to Jensen–Shannon divergence minimization. ``` The diagram below places the four families on a single map along the explicit/implicit and tractable/approximate axes, showing how each foreshadowed architecture fits.

Figure
The landscape of generative models: explicit vs. implicit, tractable vs. approximate likelihood
Generative Model Families density type likelihood tractability explicit p(x) implicit Exact likelihood • Autoregressive models chain rule: p(x)=∏ p(xᵢ|x<ᵢ) e.g. PixelCNN, GPT-style LMs • Normalizing flows invertible f, change of variables Bounded / approximate likelihood • Variational Autoencoders — maximize ELBO ≤ log p(x) encoder q(z|x) + decoder p(x|z) • Diffusion models — denoising bound on log p(x) forward noising / learned reverse process No likelihood — sampling / adversarial objective • Generative Adversarial Networks — generator G(z) vs. discriminator D(x), minimax game trained via two-sample comparison, not log-likelihood; discriminator implicitly estimates a density ratio • Only samples x̂ = G(z) are produced; p_theta(x) is never written down or evaluated Trade sample realism & speed for lack of calibrated probability and harder, less stable optimization → increasing approximation / decreasing tractability

Complexity & correctness

Time and space complexity by family. Autoregressive models. Training likelihood for a dd-dimensional input costs O(d)O(d) sequential conditional evaluations, but with masked architectures (causal convolutions, causal attention) all dd conditionals are computed in parallel in one forward pass, giving O(d)O(d) work but O(1)O(1) sequential depth relative to dd during training. Sampling, however, is inherently sequential: generating xix_i requires x1,…,xi−1x_1,\dots,x_{i-1}, so sampling costs O(d)O(d) sequential network evaluations — this asymmetry (fast parallel training, slow sequential sampling) is a defining, and honest, limitation of autoregressive models. Normalizing flows. Density evaluation costs one forward (or inverse) pass through fθf_\theta plus the log-determinant of a d×dd \times d Jacobian, which is O(d3)O(d^3) in general. Practical flow architectures (coupling layers, autoregressive flows) constrain fθf_\theta so the Jacobian is triangular, reducing the determinant to O(d)O(d) — the product of diagonal entries. This architectural constraint is what makes flows tractable at all; it is a real restriction on expressiveness, not a free lunch. VAEs. One forward pass through encoder and decoder costs O(d)O(d) (network-dependent), and the ELBO is computed with a single Monte Carlo sample of zz via the reparameterization trick, adding negligible overhead. Sampling is a single decoder forward pass — O(1)O(1) network evaluations, much faster than autoregressive sampling. GANs. One generator forward pass produces a sample, O(1)O(1) network evaluations — the fastest sampling of any family discussed. Training cost per step is one discriminator pass plus one generator pass, but the number of steps to convergence is empirically much less predictable, since there is no monotone loss to track.

Why maximum likelihood is the correct objective (explicit models). Minimizing DKL(pdata∥pθ)D_{\mathrm{KL}}(p_{\text{data}} \| p_\theta) over θ\theta is equivalent to maximizing Epdata[log⁡pθ(x)]\mathbb{E}_{p_{\text{data}}}[\log p_\theta(x)], since

DKL(pdata∥pθ)=Epdata[log⁡pdata(x)]−Epdata[log⁡pθ(x)],D_{\mathrm{KL}}(p_{\text{data}}\|p_\theta) = \mathbb{E}_{p_{\text{data}}}[\log p_{\text{data}}(x)] - \mathbb{E}_{p_{\text{data}}}[\log p_\theta(x)],

and the first term does not depend on θ\theta. Because DKL≥0D_{\mathrm{KL}} \geq 0 with equality iff pdata=pθp_{\text{data}} = p_\theta almost everywhere (Gibbs' inequality), driving the KL to its minimum value of zero — which MLE does asymptotically, as n→∞n \to \infty, under standard regularity conditions and a sufficiently expressive model class — is provably the right target. The empirical average 1n∑ilog⁡pθ(xi)\frac{1}{n}\sum_i \log p_\theta(x_i) is an unbiased Monte Carlo estimator of Epdata[log⁡pθ(x)]\mathbb{E}_{p_{\text{data}}}[\log p_\theta(x)], so gradient ascent on the sample average is a consistent estimator of the population optimum by the law of large numbers.

Why the ELBO is a valid surrogate (approximate-likelihood models). For any latent-variable model with variational posterior qϕ(z∣x)q_\phi(z\mid x),

log⁡pθ(x)=Eqϕ(z∣x)[log⁡pθ(x,z)qϕ(z∣x)]+DKL(qϕ(z∣x) ∥ pθ(z∣x))≥Eqϕ(z∣x)[log⁡pθ(x,z)qϕ(z∣x)]=ELBO.\log p_\theta(x) = \mathbb{E}_{q_\phi(z|x)}\left[\log \frac{p_\theta(x, z)}{q_\phi(z|x)}\right] + D_{\mathrm{KL}}(q_\phi(z|x) \,\|\, p_\theta(z|x)) \geq \mathbb{E}_{q_\phi(z|x)}\left[\log \frac{p_\theta(x,z)}{q_\phi(z|x)}\right] = \text{ELBO}.

Since the KL term is non-negative, the ELBO is a certified lower bound on the true log-likelihood for every xx; maximizing it maximizes a guaranteed floor on the quantity we actually care about, and the gap closes as qϕq_\phi approaches the true posterior.

Why the adversarial game targets the right divergence. At a fixed generator, the optimal discriminator is D∗(x)=pdata(x)pdata(x)+pθ(x)D^*(x) = \frac{p_{\text{data}}(x)}{p_{\text{data}}(x) + p_\theta(x)} (this is the Bayes-optimal classifier between the two distributions, derivable by maximizing the discriminator's expected log-likelihood pointwise). Substituting D∗D^* back into the value function shows the generator's objective becomes, up to a constant, 2 DJS(pdata ∥ pθ)−log⁡42\, D_{\mathrm{JS}}(p_{\text{data}} \,\|\, p_\theta) - \log 4, the Jensen–Shannon divergence. Since DJS≥0D_{\mathrm{JS}} \geq 0 with equality iff the distributions coincide, the global minimum of the generator's loss (given an optimal discriminator) is achieved exactly when pθ=pdatap_\theta = p_{\text{data}} — this is the theoretical justification for adversarial training, though it assumes an idealized, fully-optimized discriminator at every step, which practical alternating gradient descent only approximates.

Honest tradeoffs. Tractable-likelihood models give calibrated probabilities and stable, well-understood training (plain gradient ascent on a scalar objective) but pay for it — autoregressive sampling is slow, and flows require restrictive invertibility constraints that can limit expressiveness. Approximate-likelihood models relax the invertibility constraint but only optimize a bound, so the model may be penalized less for missing modes than a true likelihood would penalize it (a known failure mode of posterior-collapse in VAEs). Implicit models sample fastest and can produce the sharpest, most realistic outputs, but they lose density evaluation entirely, offer no direct measure of overfitting or mode coverage, and their non-convex minimax training can oscillate or collapse (mode collapse) rather than converge.

Worked example

Consider a toy dataset of 2-D points and three candidate ways to model p(x1,x2)p(x_1, x_2): an autoregressive factorization, a flow, and an implicit sampler. Suppose we observe n=4n = 4 points:

D={(0,0), (1,1), (2,3), (1,2)}D = \{(0,0),\ (1,1),\ (2,3),\ (1,2)\}

Step 1 — Autoregressive model. Factor pθ(x1,x2)=pθ(x1) pθ(x2∣x1)p_\theta(x_1, x_2) = p_\theta(x_1)\, p_\theta(x_2 \mid x_1). Suppose after training, the model assigns

x1x_1pθ(x1)p_\theta(x_1)x2∣x1x_2 \mid x_1pθ(x2∣x1)p_\theta(x_2 \mid x_1)
00.3000.9
10.4510.5
10.4520.4
20.2530.7

The exact joint log-likelihood of the dataset is computed by simple multiplication and summation — no integral, no approximation:

log⁡pθ(D)=log⁡(0.30⋅0.9)+log⁡(0.45⋅0.5)+log⁡(0.25⋅0.7)+log⁡(0.45⋅0.4)\log p_\theta(D) = \log(0.30 \cdot 0.9) + \log(0.45\cdot 0.5) + \log(0.25\cdot 0.7) + \log(0.45\cdot 0.4)
=log⁡0.27+log⁡0.225+log⁡0.175+log⁡0.18≈−1.309−1.492−1.743−1.715=−6.259.= \log 0.27 + \log 0.225 + \log 0.175 + \log 0.18 \approx -1.309 - 1.492 - 1.743 - 1.715 = -6.259.

This is an exact number — the defining feature of the autoregressive/flow family. Gradient ascent adjusts the conditional tables (or network weights producing them) directly on this quantity.

Step 2 — Latent-variable model (VAE-style). Now suppose instead pθ(x)=∫pθ(x∣z) p(z) dzp_\theta(x) = \int p_\theta(x\mid z)\,p(z)\,dz with a 1-D Gaussian latent zz. We cannot integrate this exactly for a neural decoder, so we instead compute the ELBO for point (1,2)(1,2) using an encoder qϕ(z∣x)=N(μ=0.3,σ2=0.8)q_\phi(z \mid x) = \mathcal{N}(\mu = 0.3, \sigma^2 = 0.8) and prior p(z)=N(0,1)p(z) = \mathcal{N}(0,1):

ELBO(x)=Eqϕ(z∣x)[log⁡pθ(x∣z)]⏟reconstruction term−DKL(qϕ(z∣x) ∥ p(z))⏟regularization term.\text{ELBO}(x) = \underbrace{\mathbb{E}_{q_\phi(z|x)}[\log p_\theta(x\mid z)]}_{\text{reconstruction term}} - \underbrace{D_{\mathrm{KL}}(q_\phi(z|x)\,\|\,p(z))}_{\text{regularization term}}.

The KL term between two Gaussians has a closed form:

DKL(N(μ,σ2) ∥ N(0,1))=12(σ2+μ2−1−log⁡σ2)=12(0.8+0.09−1−log⁡0.8)≈12(0.8+0.09−1+0.223)=0.0565.D_{\mathrm{KL}}(\mathcal{N}(\mu,\sigma^2)\,\|\,\mathcal{N}(0,1)) = \tfrac12(\sigma^2 + \mu^2 - 1 - \log\sigma^2) = \tfrac12(0.8 + 0.09 - 1 - \log 0.8) \approx \tfrac12(0.8+0.09-1+0.223) = 0.0565.

If the reconstruction term (estimated with one sampled zz via reparameterization, z=μ+σϵz = \mu + \sigma\epsilon) evaluates to, say, −1.10-1.10, then ELBO(x)≈−1.10−0.057=−1.157\text{ELBO}(x) \approx -1.10 - 0.057 = -1.157. This is not log⁡pθ(x)\log p_\theta(x) — it is guaranteed to be less than or equal to the true (uncomputable) log-likelihood. Training maximizes this quantity, trusting the bound's tightness rather than exactness.

Step 3 — Implicit model (GAN-style). Here there is no likelihood step at all. A generator maps z∼N(0,I)z \sim \mathcal{N}(0, I) to x^=Gθ(z)\hat x = G_\theta(z); suppose z=0.5z = 0.5 maps to x^=(1.1,1.9)\hat x = (1.1, 1.9). We never compute pθ((1.1,1.9))p_\theta((1.1,1.9)). Instead, the discriminator scores it: Dϕ(1.1,1.9)=0.42D_\phi(1.1, 1.9) = 0.42 (closer to 0 = "looks fake," closer to 1 = "looks real"). Training updates θ\theta to push this score toward 11 and updates ϕ\phi to keep distinguishing real points (which score near 11) from generated ones — the entire signal is comparative, sample-vs-sample, never a probability of the data. The contrast is the whole lesson: identical dataset, three fundamentally different notions of what "fitting the distribution" even means numerically.

Common pitfalls & traps

PitfallWhy it happensFix
Confusing a bound (ELBO) with the true likelihoodThe ELBO is often reported as "the log-likelihood" in papers/code, hiding the KL gapAlways state whether a number is exact or a lower bound; monitor the encoder-posterior KL term separately
Assuming flows can model any distributionInvertibility + tractable Jacobian forces restrictive layer designs (e.g., coupling layers keep half the dimensions unchanged per layer)Stack many flow layers / use expressive coupling functions; understand the architectural constraint, not just the theorem
Treating GAN loss as a convergence signalThe minimax objective is not monotone; generator and discriminator losses can oscillate even as sample quality improvesTrack sample quality metrics (FID, precision/recall) and mode coverage, not raw loss curves
Ignoring sequential sampling cost of autoregressive modelsParallel training (teacher forcing) hides the fact that generation is inherently step-by-stepBudget O(d)O(d) sequential passes for sampling; consider caching or non-autoregressive alternatives if latency matters
Mode collapse in implicit modelsGenerator finds a small region of output space that reliably fools the current discriminatorUse architectural/training fixes (minibatch discrimination, alternative divergences, gradient penalties); track diversity metrics explicitly

Pioneers & history

The generative modeling paradigm draws on a century of probability and statistics, crystallized into deep learning through a sequence of foundational papers connecting neural networks to explicit and implicit density estimation.

Origins · 1 minIan J. Goodfellow and how this was discovered
IJ
Ian J. Goodfellow
born 1985 · introduced Generative Adversarial Networks in 2014, reframing generative modeling as a two-player minimax game and establishing the implicit-density paradigm as a first-class alternative to likelihood-based training

History
1950
s — foundational theory of maximum likelihood estimation formalized in mathematical statistics, long predating neural implementations.
2013
— Kingma and Welling introduce the Variational Autoencoder, combining amortized variational inference with deep neural decoders and the reparameterization trick.
2014
— Goodfellow et al. introduce Generative Adversarial Networks, establishing implicit, sampling-based generative training via an adversarial game.
2015-2016
— autoregressive image models (PixelRNN, PixelCNN) and normalizing-flow architectures (NICE, Real NVP) demonstrate tractable exact-likelihood generative modeling at scale.
2020
s — denoising diffusion probabilistic models unify score-based and variational perspectives, becoming a dominant approximate-likelihood paradigm for high-fidelity image and audio synthesis.

Where this matters

Explicit autoregressive models power large language models: every modern text generator (GPT-family and successors) is, at its core, an autoregressive density model over tokens trained by maximum likelihood, exactly the mechanism described above. Normalizing flows are used in scientific simulation (lattice field theory, molecular conformer generation) where exact density evaluation is required for downstream physics calculations, and in some fast, invertible audio vocoders. Variational Autoencoders and their descendants underlie representation learning pipelines, anomaly detection systems, and are a core building block inside modern latent diffusion image generators (compressing images into a latent space before the diffusion process operates). Generative Adversarial Networks, despite training instability, remain widely used for fast, high-resolution image synthesis, super-resolution, image-to-image translation, and data augmentation in domains such as medical imaging where labeled data is scarce. Diffusion models, which combine the variational/approximate-likelihood viewpoint with an iterative sampling procedure, currently dominate state-of-the-art image, video, and audio generation systems (e.g., large-scale text-to-image and text-to-video systems), and represent the natural next architecture built directly on the concepts introduced here.

Ask the tutor: How does the reparameterization trick make the ELBO differentiable with respect to the encoder's parameters?

What is the difference between a generative model and a discriminative model?

A generative model learns (an approximation to) the joint or marginal distribution of the data, pθ(x)p_\theta(x) or pθ(x,y)p_\theta(x,y), and can therefore be used to sample new data or evaluate how likely a given input is. A discriminative model learns only the conditional p(y∣x)p(y\mid x) needed to predict a label from an input, and typically cannot generate new xx's or assess whether an input is unusual. Generative models are strictly attempting a harder problem — modeling the full data distribution — which is why they support tasks discriminative models cannot, like synthesis and anomaly detection, but they can also be more difficult to train well, especially in high dimensions with complex, multimodal distributions.

Why can't we always compute the exact likelihood for latent-variable models like VAEs?

The likelihood is pθ(x)=∫pθ(x∣z) p(z) dzp_\theta(x) = \int p_\theta(x\mid z)\, p(z)\, dz, an integral over all possible latent values zz that explain xx. When pθ(x∣z)p_\theta(x\mid z) is parameterized by a deep neural network, this integral has no closed form and cannot be computed by quadrature in reasonable time for continuous, high-dimensional zz. Instead, we introduce an approximate posterior qϕ(z∣x)q_\phi(z\mid x) and optimize the Evidence Lower Bound, which is tractable via Monte Carlo sampling and the reparameterization trick, and which is provably a lower bound on the true (unreachable) log-likelihood.

Are GANs strictly better than likelihood-based models because they produce sharper images?

Not strictly better — they trade one set of strengths for another. GANs often produce sharper, more realistic-looking samples partly because their adversarial loss does not penalize the generator for placing zero probability mass on regions of the true data distribution (a behavior related to mode-seeking vs. mode-covering divergences), whereas likelihood-based training tends to spread probability mass more conservatively to avoid catastrophically low likelihood on any training point. This can make GAN samples look crisper but at the cost of reduced diversity (mode collapse), unstable non-convex minimax training, and the complete absence of a usable density function for tasks like anomaly detection or exact model comparison.

What does "tractable likelihood" actually require architecturally?

For autoregressive models, tractability requires only that each conditional factor pθ(xi∣x<i)p_\theta(x_i \mid x_{<i}) be a normalized distribution (e.g., softmax over discrete values, or a Gaussian/mixture density for continuous ones), so the chain-rule product is automatically a valid, normalized joint density. For normalizing flows, tractability requires the transformation fθf_\theta to be invertible with a Jacobian whose determinant can be computed cheaply — typically enforced by restricting layers to triangular Jacobians (coupling layers, autoregressive flows), so the determinant reduces to a product of diagonal entries computable in O(d)O(d) rather than the generic O(d3)O(d^3) cost of a dense determinant.

How does maximum likelihood estimation connect to the Kullback–Leibler divergence?

The KL divergence from the true data distribution to the model, DKL(pdata∥pθ)D_{\mathrm{KL}}(p_{\text{data}}\|p_\theta), expands into the negative entropy of the data (a constant, independent of θ\theta) minus the expected log-likelihood under the model. Since the constant term doesn't affect optimization, minimizing this KL divergence over θ\theta is exactly equivalent to maximizing Epdata[log⁡pθ(x)]\mathbb{E}_{p_{\text{data}}}[\log p_\theta(x)], which is estimated in practice by the empirical average 1n∑ilog⁡pθ(xi)\frac{1}{n}\sum_i \log p_\theta(x_i) — the maximum likelihood objective. This equivalence is why MLE is often described as "distribution matching" rather than merely a statistical estimation heuristic.

Why does the adversarial training objective correspond to Jensen–Shannon divergence rather than KL divergence?

Substituting the Bayes-optimal discriminator D∗(x)=pdata(x)pdata(x)+pθ(x)D^*(x) = \frac{p_{\text{data}}(x)}{p_{\text{data}}(x)+p_\theta(x)} back into the GAN value function algebraically reduces it to 2 DJS(pdata∥pθ)−log⁡42\,D_{\mathrm{JS}}(p_{\text{data}}\|p_\theta) - \log 4, a fact that follows directly from the definition of Jensen–Shannon divergence as an average of two KL divergences to the mixture distribution. This derivation, given in the original GAN paper, is what licenses calling GAN training "divergence minimization" despite never computing any density: the discriminator's role is precisely to make that divergence's gradient estimable through samples alone.

Which family should I use if I need exact density values, e.g., for anomaly detection?

Prefer autoregressive models or normalizing flows, since both provide an exact, computable log⁡pθ(x)\log p_\theta(x) for any input, letting you flag low-likelihood points as anomalies with a principled threshold. VAEs can approximate this with the ELBO, but since the ELBO is only a lower bound (with an unknown, input-dependent gap), likelihood-based anomaly scores derived from it can be biased or miscalibrated across different types of inputs. GANs are generally unsuitable for this task directly, since they provide no likelihood at all — anomaly detection with GANs typically requires auxiliary tricks like reconstruction error through an inverted generator, which is an indirect and less theoretically grounded proxy.

Where this leads