Notes on the Four Major AIGC Generative Models: Principles, Derivations, and Pseudocode for VAE, GAN, Normalizing Flow, and Diffusion Models
Review notes on generative models (generative model: a probabilistic model that learns a data distribution and can sample new examples), written in the same style as the site's Deep Reinforcement Learning Core Algorithms Notes. They first explain the problem framework shared by the four routes (explicit versus implicit density, the mismatch between likelihood and perceptual quality, the limitations of evaluation metrics, and where the training signal comes from), then unfold one by one — along the same skeleton of 'why it is needed → principles and formulas → collapsible derivations → complete pseudocode → section-by-section walkthrough → per-step read/write and state-maintenance checklist → pitfall list → scope of application' — the Variational Autoencoder (VAE), the Generative Adversarial Network (GAN), Normalizing Flow, and the Diffusion Model. The article contains 32 collapsible derivations, covering the complete decomposition of the evidence lower bound, the closed form of the KL divergence between two diagonal Gaussians, the gradient validity of reparameterization, the optimal discriminator and the Jensen-Shannon divergence, the gradient scale of the non-saturating loss, the Kantorovich-Rubinstein duality of the Wasserstein distance, the vanishing JS gradient when distributions do not overlap, the change-of-variables formula, the triangular Jacobian of coupling layers, the log-determinant of the invertible 1×1 convolution, the instantaneous change of variables and trace estimation of continuous flows, the closed-form forward marginal distribution, the term-by-term rearrangement of the evidence lower bound, the simplified loss, the Tweedie formula and the denoising equivalence, the deterministic update of DDIM, why the importance-weighted bound is tighter than the evidence lower bound, the Lagrangian interpretation of β-VAE and free bits, the variational lower bound of an arbitrary f-divergence and its optimal discriminator for f-GAN, why the gradient penalty of WGAN-GP is equivalent to a gradient norm of one, the inverse transform of coupling layers and the triangular Jacobian of autoregressive flows, dequantization and the +log2 256 volume factor in bits per dimension, the signal-to-noise-ratio weighting implied by the simplified loss, and the source of the score in classifier-free guidance and the extrapolation of γ>1, as well as the saddle-point difference between the GAN minimax and the VAE maximized lower bound, FID as the Fréchet distance between two Gaussians in feature space, the equivalence between the reconstruction term and the mean squared error, the quantitative condition for posterior collapse, the Lipschitz upper bound of spectral normalization and power iteration, a toy counterexample for mode collapse, the conversion among the four diffusion parameterizations (x0, noise, mean, and v), and the Euler discretization relation between the probability-flow ODE and DDIM; the final chapter puts the four models back into a single coordinate system with one master table, six key disagreements, one model-selection decision chain, and a concept correspondence table against reinforcement learning.