Contents
Generative vs Discriminative Models/Chapter 10 of 10
10Summary
- Two views: p(x,y)=p(y)\,p(x\mid y)=p(x)\,p(y\mid x). Generative = p(y)\,p(x\mid y) or p(x) (the painter, can create); discriminative = p(y\mid x) (the critic, only judges).
- Bayes’ theorem: p(y\mid x)=p(x\mid y)\,p(y)/p(x); likelihoods 0.30 and 0.05, equal priors: p(\text{cat}\mid x)=0.857. Two classes: p(y=1\mid x)=\sigma(a) with a = log likelihood ratio + log prior odds.
- Gaussian discriminant analysis: fit by counts and averages; shared \Sigma \Rightarrow \sigma(w^\top x+b), w=\Sigma^{-1}(\mu_1-\mu_0) (LDA); separate \Sigma_c \Rightarrow quadratic boundary (QDA).
- Naive Bayes: p(x\mid y)=\prod_dp(x_d\mid y); Bernoulli: w_d=\log\frac{\theta_{d1}(1-\theta_{d0})}{\theta_{d0}(1-\theta_{d1})}, again logistic. Generative–discriminative pairs differ in the objective: joint versus conditional likelihood.
- Logistic regression: \sigma(w^\top x+b); loss = cross-entropy; gradient \sum_n(\mu_n-y_n)x_n; convex, no closed form; M+1 parameters versus M(M+5)/2+1 for shared-covariance Gaussians.
- Generative models create: autoregressive p(x)=\prod_tp(x_t\mid x_{<t}) (GPT, WaveNet); diffusion x_t=\sqrt{\bar\alpha_t}x_0+\sqrt{1-\bar\alpha_t}\epsilon, loss \|\epsilon-\epsilon_\theta\|^2, many steps; flow matching x_t=(1-t)x_0+tx_1, loss \|v_\theta-(x_1-x_0)\|^2, few steps because straight paths have no curvature; GAN D^\star=p_{\text{data}}/(p_{\text{data}}+p_g).
- Who wins: discriminative has lower asymptotic error, generative converges faster (O(\log n) versus O(n) examples; Ng and Jordan). Digits 4 vs 9: crossover at about 23 examples; 1.7\% versus 0.8\% at 200.
- Only the painter: generates, marginalizes missing features (ears only: p(\text{cat})=0.813), flags outliers with p(x) (the fox: 1.6\times10^{-8}), adds classes without retraining, uses unlabelled data. The critic: more accurate with enough data, arbitrary features, better calibrated.