Math Foundations: SVD, Eigendecomposition, Matrix Calculus, and ELBO Derivation
4735 words
24 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Math Foundations: SVD, Eigendecomposition, Matrix Calculus, and ELBO Derivation ## ๐ฏ Learning Objectives - Compute and interpret singular value decomposition (SVD) and eigendecomposition - Understand matrix calculus for gradient-based optimization - Derive the ELBO from first principles with full mathematical det...

Math Foundations: SVD, Eigendecomposition, Matrix Calculus, and ELBO Derivation
๐ฏ Learning Objectives
- Compute and interpret singular value decomposition (SVD) and eigendecomposition
- Understand matrix calculus for gradient-based optimization
- Derive the ELBO from first principles with full mathematical detail
- Apply optimization concepts to generative model training
- Connect linear algebra to key generative model operations
๐ Prerequisites
- Linear algebra basics: Vectors, matrices, matrix multiplication
- Calculus: Partial derivatives, chain rule
- Probability: Expectation, Bayes rule, KL divergence
- Generative Models Overview (Week 1): Basic ML concepts
1. ๐ Core Content
1.1 Intuition: Why Math Matters for Generative AI
Every generative model is built on mathematical foundations:
- Linear algebra powers the transformations in neural networks โ matrix multiplications, convolutions, attention mechanisms. SVD and eigendecomposition are used for PCA (preprocessing), understanding latent spaces, and analyzing optimization landscapes.
- Matrix calculus enables gradient-based learning โ backpropagation is repeated application of the chain rule on matrix expressions.
- Optimization theory explains why certain training strategies work โ SGD, Adam, learning rate schedules all exploit properties of the loss landscape.
- The ELBO is the central objective for VAEs, diffusion models, and many other generative models. Understanding its derivation is essential for debugging and extending these models.
1.2 Eigenvalues and Eigenvectors
1.2.1 Definition
For a square matrix AโRnรn, a non-zero vector vโRn is an eigenvector with corresponding eigenvalue ฮป if:
This means: multiplying A with v is equivalent to scaling v by ฮป. The eigenvector's direction is preserved; only its magnitude changes.
1.2.2 Intuition
Think of A as a transformation that stretches/compresses space. Eigenvectors are the "special directions" that are only scaled, not rotated. The eigenvalue tells you how much stretching occurs along that direction.
- โฃฮปโฃ>1: Stretching
- โฃฮปโฃ<1: Compression
- โฃฮปโฃ=1: Unchanged
- ฮป=0: Direction is in the nullspace
1.2.3 Eigendecomposition
If A has n linearly independent eigenvectors, we can diagonalize it:
where:
- V: Matrix whose columns are eigenvectors
- ฮ: Diagonal matrix of eigenvalues diag(ฮป1โ,...,ฮปnโ) For real symmetric matrices (A=AT), eigenvectors are orthogonal, so Vโ1=VT:
Worked Example 1: Eigendecomposition of a 2ร2 Matrix
Find eigenvalues and eigenvectors of
.
Step 1: Solve characteristic equation det(AโฮปI)=0:
Step 2: Find eigenvector for ฮป1โ: (Aโฮป1โI)v1โ=0
From first row: โ0.618v11โ+v12โ=0โนv12โ=0.618v11โ
So
, normalized:
Step 3: Similarly for ฮป2โ:
Step 4: Verify: VTAV=ฮ
1.3 Singular Value Decomposition (SVD)
SVD generalizes eigendecomposition to non-square matrices. Any matrix AโRmรn can be decomposed as:
where:
- UโRmรm: Left singular vectors (orthogonal columns, UTU=I)
- ฮฃโRmรn: Diagonal matrix of singular values ฯ1โโฅฯ2โโฅ...โฅฯrโ>0
- VโRnรn: Right singular vectors (orthogonal columns, VTV=I)
- r: Rank of A (number of non-zero singular values)
1.3.1 Intuition
SVD reveals what A does as a linear transformation:
- VT rotates the input to align with a new coordinate system
- ฮฃ scales each coordinate by ฯiโ
- U rotates the result to produce the output (Diagram)
1.3.2 Relationship to Eigendecomposition
For ATA (a square symmetric matrix):
So:
- V contains eigenvectors of ATA
- ฯi2โ=ฮปiโ (singular values squared = eigenvalues of ATA) Similarly, U contains eigenvectors of AAT.
Worked Example 2: SVD of a 2ร2 Matrix
Compute SVD of
.
Step 1: Compute
Step 2: Find eigenvalues of ATA:
Singular values: ฯ1โ=16โ=4, ฯ2โ=4โ=2
Step 3: Find eigenvectors of ATA for V:
For ฮป1โ=16:
For ฮป2โ=4:
Step 4: Compute U: uiโ=ฯiโAviโโ
Step 5: Verify:
1.4 Matrix Calculus
For training neural networks, we need gradients of scalar loss functions with respect to matrix parameters.
1.4.1 Key Rules
| Operation | Gradient |
|---|---|
| โxโโ(aTx)=a | Linear form |
| โxโโ(xTAx)=(A+AT)x | Quadratic form |
| โXโโTr(AX)=AT | Trace |
| โXโโdet(X)=det(X)(Xโ1)T | Determinant |
| $\frac{\partial}{\partial X} \ | X\ |
Worked Example 3: Gradient of a Quadratic Form
Compute โxโf(x) where f(x)=(xโฮผ)Tฮฃโ1(xโฮผ) (Mahalanobis distance squared).
Step 1: Expand: Let y=xโฮผ, then f=yTฮฃโ1y.
Step 2: Using โyโโ(yTAy)=(A+AT)y with A=ฮฃโ1 (which is symmetric):
Step 3: Chain rule:
1.4.2 Gradients of Log-Likelihood for Gaussians
For a multivariate Gaussian p(x)=N(xโฃฮผ,ฮฃ):
Gradient w.r.t. ฮผ:
Gradient w.r.t. ฮฃโ1 (natural parameterization):
These gradients are used in:
- MLE for Gaussian models
- VAE training (Gaussian encoder/decoder)
- KL divergence computation in diffusion models
1.5 Optimization for Generative Models
1.5.1 Convex vs Non-Convex Optimization
Convex functions: Bowl-shaped, any local minimum is global. Guaranteed convergence for gradient descent.
Non-convex functions: Multi-modal, multiple local minima. Neural network training landscapes are non-convex.
Generative model training is highly non-convex due to:
- Neural network parameterizations
- Min-max objectives (GANs)
- Latent variable marginalization (VAEs)
1.5.2 Stochastic Gradient Descent (SGD)
ฮธt+1โ=ฮธtโโฮทtโโฮธโLBโ(ฮธtโ)where LBโ is the loss computed on a mini-batch B.
Why SGD works for generative models:
- Efficient for large datasets (compute gradient on subset)
- Noise helps escape shallow local minima
- Generalizes better than full-batch gradient descent
1.5.3 Adam Optimizer
Adam combines momentum + adaptive learning rates:
Recommended defaults for generative models:
- ฮฒ1โ=0.9,ฮฒ2โ=0.999,ฮท=1eโ4 (GANs), 3eโ4 (diffusion models)
- Lower learning rates for discriminator/critic (two-timescale update rule)
1.6 The ELBO: Full Derivation
The Evidence Lower Bound (ELBO) is the central objective for VAEs and many other generative models.
1.6.1 The Problem
We have a latent variable model:
This integral is intractable for complex models (neural network decoders) because we'd need to integrate over all possible z.
1.6.2 Introducing the Variational Distribution
We introduce an approximate posterior qฯโ(zโฃx) (the encoder). The goal: make qฯโ(zโฃx) close to the true posterior pฮธโ(zโฃx).
1.6.3 Derivation Step 1: Start with Log-Likelihood
logpฮธโ(x)=logโซpฮธโ(xโฃz)p(z)dz1.6.4 Derivation Step 2: Multiply by 1 = q/q
logpฮธโ(x)=logโซqฯโ(zโฃx)โ qฯโ(zโฃx)pฮธโ(xโฃz)p(z)โdz1.6.5 Derivation Step 3: Apply Jensen's Inequality
For a concave function (log is concave), log(E[y])โฅE[log(y)]:
The RHS is the ELBO, denoted L(x;ฮธ,ฯ).
1.6.6 Derivation Step 4: Rearrange the ELBO
L(x;ฮธ,ฯ)=Eqฯโ(zโฃx)โ[logpฮธโ(xโฃz)]+Eqฯโ(zโฃx)โ[logqฯโ(zโฃx)p(z)โ] =ReconstructionEqฯโ(zโฃx)โ[logpฮธโ(xโฃz)]โโโKLย divergenceDKLโ(qฯโ(zโฃx)โฅp(z))โโ1.6.7 Derivation Step 5: The Gap
The gap between the true log-likelihood and the ELBO is the KL divergence between qฯโ(zโฃx) and the true posterior pฮธโ(zโฃx):
Proof:
1.6.8 The Reparameterization Trick
The ELBO requires gradient through Ezโผqฯโ(zโฃx)โ[logpฮธโ(xโฃz)], but z is sampled stochastically. Since sampling is non-differentiable, we reparameterize:
Now the expectation is over ฯต (which doesn't depend on ฯ), and the gradient can flow through ฮผฯโ and ฯฯโ:
1.7 Why This Matters
The mathematical tools covered here are used throughout generative AI:
- SVD: PCA for data preprocessing, analyzing latent space structure, low-rank approximations (LoRA) for fine-tuning
- Eigendecomposition: Understanding covariance structure of features, FID computation
- Matrix calculus: Every gradient-based training loop
- Optimization: Choosing optimizers (Adam vs SGD), learning rate schedules, warmup
- ELBO: Foundations of VAEs, diffusion models (which can be seen as hierarchical VAEs)
2. ๐ Key Formulas / Concepts
| Concept | Formula | Application in GenAI |
|---|---|---|
| Eigendecomposition | A=VฮVT (symmetric) | PCA, covariance analysis |
| SVD | A=UฮฃVT | Low-rank approximations, latent structure |
| Quadratic gradient | โxโ(xTAx)=2Ax (A symmetric) | Gaussian gradient computation |
| ELBO | $\mathcal{L} = \mathbb{E}q[\log p\theta(x | z)] - D_{KL}(q_\phi(z |
| Reparameterization | z=ฮผ+ฯโ ฯต | Differentiable sampling |
| Adam update | ฮธt+1โ=ฮธtโโฮทvtโโ+ฯตmtโโ | Default optimizer for gen models |
3. โ ๏ธ Common Pitfalls
Pitfall 1: Confusing SVD and Eigendecomposition
Mistake: Using eigendecomposition when SVD is needed (for non-square matrices).
Why: Eigendecomposition only works for square matrices. SVD works for any matrix.
Correct approach: Use eigendecomposition for analyzing square symmetric matrices (covariance matrices, Gram matrices). Use SVD for data matrices, weight matrices, and any non-square case.
Pitfall 2: Forgetting the Reparameterization Trick Isn't Always Applicable
Mistake: Trying to apply the reparameterization trick to discrete latent variables.
Why: The reparameterization trick requires the sampling distribution to be reparameterizable as a deterministic function of a noise source. For discrete distributions (e.g., categorical), z takes discrete values and can't be written as ฮผ+ฯโ
ฯต with ฯตโผN(0,I).
Correct approach: Use the Gumbel-Softmax trick (continuous relaxation of discrete sampling) or REINFORCE gradient estimator for discrete latents.
Pitfall 3: Ignoring the KL Vanishing Problem
Mistake: Training a VAE and wondering why the latent variables aren't used.
Why: The KL term in the ELBO encourages qฯโ(zโฃx) to match the prior p(z). If the decoder is powerful enough, the model can "ignore" z and set qฯโ(zโฃx)=p(z), resulting in DKLโ=0 but no meaningful latent representation.
Correct approach: Monitor KL divergence during training. If it drops to near zero, use KL annealing, free bits (a minimum KL per dimension), or reduce decoder capacity.
Pitfall 4: Using SGD when Adam is Needed
Mistake: Using vanilla SGD for GAN or VAE training with poor results.
Why: Generative model losses are highly non-convex and have varying gradient scales across parameters. SGD's fixed learning rate per parameter struggles. Adam's adaptive learning rates handle the varying scales better.
Correct approach: Use Adam for most generative models. For GANs, use two-timescale Adam (different learning rates for generator and discriminator).
Pitfall 5: Mishandling Matrix Calculus Gradients
Mistake: Computing matrix gradients as scalars without respecting transpose relationships.
Why: โWโfโ has the same dimensions as W, but the chain rule for matrix functions requires attention to transposition.
Correct approach: Use dimensional analysis. If f=โฅWxโyโฅ2:
- f is scalar
- W is doutโรdinโ
- โWโfโ=2(Wxโy)xT (check: doutโรdinโ โ)
4. ๐ Practice Questions
>A=[21โ12โ]>**Q1: Compute the eigenvalues of
>A=[21โ12โ]=VฮVT=21โ[11โ1โ1โ][30โ01โ][11โ1โ1โ]>and explain what they mean geometrically.**Step 1: det(AโฮปI)=(2โฮป)2โ1=ฮป2โ4ฮป+3=0Step 2: ฮป=24ยฑ16โ12โโ=24ยฑ2โStep 3: ฮป1โ=3, ฮป2โ=1Geometric interpretation: A stretches space by a factor of 3 along eigenvectors corresponding to ฮป1โ and by 1 (no stretch) along eigenvectors corresponding to ฮป2โ.Eigenvectors:
ฮป1โ=3: v1โ=[1,1]T/2โ (direction of equal increase) ฮป2โ=1: v2โ=[1,โ1]T/2โ (direction of difference)
>A=[10โ02โ00โ]>**Q2: Compute the SVD of
>AAT=[10โ04โ]>.**Step 1: A is 2ร3, so U is 2ร2, ฮฃ is 2ร3, V is 3ร3.Step 2:
>v1โ=ฯ1โATu1โโ=21โโ100โ020โโ[01โ]=21โโ020โโ=โ010โโ>, eigenvalues: ฮป1โ=4, ฮป2โ=1.Singular values: ฯ1โ=2, ฯ2โ=1.Step 3: U from eigenvectors of AAT: u1โ=[0,1]T, u2โ=[1,0]T.Step 4: V from V=ATUฮฃโ1 (more carefully):ฮฃ=[diag(2,1),02ร1โ]
>v2โ=ฯ2โATu2โโ=11โโ100โ020โโ[10โ]=โ100โโ>
>UฮฃVT=[01โ10โ][20โ01โ00โ]โ010โ100โ001โโ=[10โ02โ00โ]=A>v3โ is in the nullspace of A (since Av3โ=0): v3โ=[0,0,1]T.Step 5: Verify:
Q3: Compute โxโf for f(x)=โฅAxโbโฅ22โ.Step 1: Expand: f=(Axโb)T(Axโb)=xTATAxโ2bTAx+bTbStep 2: Differentiate each term:
- โxโโ(xTATAx)=2ATAx
- โxโโ(โ2bTAx)=โ2ATb
- โxโโ(bTb)=0
Step 3: โxโf=2ATAxโ2ATb=2AT(Axโb) Q4: Starting from logp(x), derive the ELBO and show that optimizing it maximizes a lower bound on the log-likelihood.The derivation is in Section 1.6 above. The key steps:
- logp(x)=logโซp(xโฃz)p(z)dz
- Introduce q(zโฃx): logp(x)=logโซq(zโฃx)q(zโฃx)p(xโฃz)p(z)โdz
- Jensen's inequality: logEqโ[f]โฅEqโ[logf]
- Result: logp(x)โฅEqโ[logp(xโฃz)]โDKLโ(q(zโฃx)โฅp(z))=ELBO
Optimizing ฮธ,ฯ to maximize the ELBO:
- Increases the log-likelihood (by at least as much as the ELBO increases)
- Decreases DKLโ(qฯโ(zโฃx)โฅpฮธโ(zโฃx)) (the approximation gap)
The tightness depends on how well qฯโ(zโฃx) approximates the true posterior pฮธโ(zโฃx). Q5: In the reparameterization trick, why can't we just differentiate through the sampling operation directly?The sampling operation zโผqฯโ(zโฃx) is a stochastic process. The gradient of this operation w.r.t. ฯ would require differentiating through a random number generator, which is non-differentiable.Concretely, z=sample(ฮผฯโ,ฯฯโ) involves calling a random number generator to produce ฯตโผN(0,1), then computing z=ฮผฯโ+ฯฯโฯต. The RNG call has no gradient (the operation is discrete โ a number is drawn; there's no continuous path for gradient flow).The reparameterization trick moves the stochasticity to an independent noise source ฯต:z=ฮผฯโ(x)+ฯฯโ(x)โ ฯต,ฯตโผN(0,1)Now:
- The gradient can flow through ฮผฯโ and ฯฯโ (differentiable operations)
- ฯต is independent of ฯ, so no gradient through sampling
- The expectation is still valid because N(zโฃฮผ,ฯ2)dz=N(ฯตโฃ0,1)dฯต Q6: For a covariance matrix ฮฃ, explain why ฮฃ must be positive semidefinite and how eigendecomposition reveals this.
A covariance matrix must be positive semidefinite (PSD) because for any vector v:vTฮฃv=vTE[(Xโฮผ)(Xโฮผ)T]v=E[vT(Xโฮผ)(Xโฮผ)Tv]=E[(vT(Xโฮผ))2]โฅ0The variance of any linear combination is non-negative.By eigendecomposition, ฮฃ=VฮVT. PSD means all eigenvalues ฮปiโโฅ0. This is evident because:
- If any ฮปiโ<0, then viTโฮฃviโ=ฮปiโ<0 (contradiction)
- The singular values from SVD of the data matrix are ฮปiโโ, confirming non-negativity
This PSD property ensures:
- FID computation (matrix square root) is valid
- KL divergence between Gaussians is well-defined
- Cholesky decomposition for efficient sampling exists Q7: A VAE uses Adam with default parameters (ฮท=0.001, ฮฒ1โ=0.9, ฮฒ2โ=0.999). After 100 epochs, the KL term is 0.01 (near zero). Diagnose the problem and propose a fix.
Diagnosis: KL vanishing. The model is ignoring the latent variable z and functioning as an autoencoder with no regularization. The decoder is powerful enough to reconstruct x without z, so the KL term forces q(zโฃx)โp(z)=N(0,I), giving DKLโโ0.Fixes (in order of recommendation):
KL annealing: Start with ฮฒ=0 in L=Reconโฮฒโ KL, gradually increase ฮฒ from 0 to 1 over training. This lets the model learn meaningful latent representations before the KL penalty kicks in. Free bits: Set a minimum KL per dimension: KLminโ=max(ฮฒโ KL,ฮป). This ensures each dimension carries at least ฮป nats of information. Reduce decoder capacity: A weaker decoder (fewer layers, smaller hidden size) forces the model to use the latent code. Increase latent dimension: More dimensions give the model more capacity to encode information before the KL penalty forces them to the prior.Q8: Show that โฮธโExโผpฮธโโ[f(x)]=Exโผpฮธโโ[f(x)โฮธโlogpฮธโ(x)] (the REINFORCE/score function gradient).Step 1: Write the expectation as an integral:โฮธโExโผpฮธโโ[f(x)]=โฮธโโซf(x)pฮธโ(x)dxStep 2: Swap gradient and integral (under smoothness conditions):=โซf(x)โฮธโpฮธโ(x)dxStep 3: Use the log-derivative trick: โฮธโpฮธโ(x)=pฮธโ(x)โฮธโlogpฮธโ(x)=โซf(x)pฮธโ(x)โฮธโlogpฮธโ(x)dxStep 4: Recognize as an expectation:=Exโผpฮธโโ[f(x)โฮธโlogpฮธโ(x)]This is the REINFORCE gradient estimator or score function estimator. It allows gradient estimation through non-differentiable sampling by using logpฮธโ(x) instead of โฮธโx.Comparison with reparameterization:
- Reparameterization: Lower variance, but requires continuous x and differentiable f
- REINFORCE: Higher variance, but works for discrete x and non-differentiable f Q9: For a multivariate Gaussian N(ฮผ,ฮฃ), derive the gradient of the log-likelihood with respect to ฮผ for a single sample x.
Step 1: Write the log-likelihood:logp(xโฃฮผ,ฮฃ)=โ21โ(xโฮผ)Tฮฃโ1(xโฮผ)โ21โlogโฃฮฃโฃโ2Dโlog(2ฯ)Step 2: Only the first term depends on ฮผ:โฮผโlogp(xโฃฮผ,ฮฃ)=โ21โโฮผโ[(xโฮผ)Tฮฃโ1(xโฮผ)]Step 3: Let y=xโฮผ. Then โฮผโyโ=โI.Step 4: โyโโ(yTฮฃโ1y)=2ฮฃโ1y (since ฮฃโ1 is symmetric)Step 5: Chain rule:โฮผโlogp=โ21โโ โyโ(yTฮฃโ1y)โโ โฮผโyโ=โ21โโ (2ฮฃโ1y)Tโ (โI)=yTฮฃโ1=(xโฮผ)Tฮฃโ1In column-vector convention: โฮผโlogp=ฮฃโ1(xโฮผ).The MLE for ฮผ sets this gradient to zero: ฮฃโ1(ฮผ^โโxavgโ)=0โนฮผ^โ=N1โโxiโ, confirming that the MLE for the mean is the sample mean. Q10: Explain why Adam's bias correction is important in the first few iterations of VAE training.Without bias correction, Adam's moment estimates are biased toward zero because they're initialized as m0โ=0,v0โ=0:mtโ=ฮฒ1โmtโ1โ+(1โฮฒ1โ)gtโIn early iterations, mtโ is "warmed up" from 0. For ฮฒ1โ=0.9:
- t=1: m1โ=0.9โ 0+0.1โ g1โ=0.1g1โ (10% of true gradient)
- t=5: m5โโ0.41gavgโ (still biased)
- t=20: m20โโ0.88gavgโ (approaching true)
Bias correction divides by 1โฮฒ1tโ:m^tโ=1โฮฒ1tโmtโโ
- t=1: m^1โ=0.1g1โ/(1โ0.9)=g1โ โ
- t=5: m^5โโ0.41gavgโ/(1โ0.95)=0.41/0.41โgavgโ โ
Without bias correction, the first steps would be too small, slowing convergence โ particularly noticeable in VAE training where initial gradients guide the model toward meaningful latent representations. Q11: Derive the gradient of DKLโ(qฯโ(zโฃx)โฅp(z)) with respect to ฯ where qฯโ(zโฃx)=N(ฮผฯโ,ฯฯ2โ) and p(z)=N(0,1).Step 1: Write the KL in closed form for Gaussians:DKLโ(N(ฮผ,ฯ2)โฅN(0,1))=logฯ1โ+2ฯ2+ฮผ2โโ21โ=โlogฯ+2ฯ2+ฮผ2โโ21โStep 2: Differentiate w.r.t. ฮผ:โฮผโKLโ=ฮผStep 3: Differentiate w.r.t. ฯ (using ฯ as the standard deviation):โฯโKLโ=โฯ1โ+ฯ=ฯโฯ1โ=ฯฯ2โ1โStep 4: In practice, we parameterize logฯ2 (log-variance) for numerical stability. Let s=logฯ2, so ฯ=es/2:โsโKLโ=โฯโKLโโ โsโฯโ=(ฯโฯ1โ)โ 2es/2โ=(es/2โeโs/2)โ 2es/2โ=2esโ1โ=2ฯ2โ1โThe gradient tells us:
- If ฮผ>0, push ฮผ toward zero (reduce mean)
- If ฯ>1, push ฯ toward 1 (reduce variance)
- If ฯ<1, push ฯ toward 1 (increase variance)
The KL pushes the posterior toward a unit Gaussian โ neither too wide nor too narrow. Q12: In diffusion models, the training loss L=Et,x0โ,ฯตโ[โฅฯตโฯตฮธโ(xtโ,t)โฅ2] resembles a denoising objective. Show how this relates to the ELBO.The diffusion model's variational bound can be written as:Lvbโ=โt=1TโEx0โ,ฯตtโโ[DKLโ(q(xtโ1โโฃxtโ,x0โ)โฅpฮธโ(xtโ1โโฃxtโ))]Each KL term is between two Gaussians:
- q(xtโ1โโฃxtโ,x0โ)=N(ฮผ~โtโ(xtโ,x0โ),ฮฒ~โtโI) (the forward posterior, known)
- pฮธโ(xtโ1โโฃxtโ)=N(ฮผฮธโ(xtโ,t),ฯt2โI) (the model, learned)
Using the closed-form KL for Gaussians:DKLโ(qโฅpฮธโ)=2ฯt2โ1โโฅฮผ~โtโ(xtโ,x0โ)โฮผฮธโ(xtโ,t)โฅ2+constWe parameterize ฮผฮธโ as:ฮผฮธโ(xtโ,t)=ฮฑtโโ1โ(xtโโ1โฮฑหtโโฮฒtโโฯตฮธโ(xtโ,t))And the forward posterior mean is:ฮผ~โtโ(xtโ,x0โ)=ฮฑtโโ1โ(xtโโ1โฮฑหtโโฮฒtโโฯตtโ)Substituting, the KL simplifies to:DKLโ(qโฅpฮธโ)โโฅฯตtโโฯตฮธโ(xtโ,t)โฅ2Thus, the diffusion training loss โฅฯตโฯตฮธโ(xtโ,t)โฅ2 is equivalent to minimizing the KL divergence between the true denoising step and the model's prediction at each timestep โ which is exactly the ELBO for diffusion models. This demonstrates the deep connection between denoising score matching and variational inference.
5. ๐ Cross-References
- All BSDA5002 topics: This math is used throughout
- Information Theory (Week 9) (../week09/09-information-theory.md) โ KL divergence, entropy
- VAEs (Week 3) (../week03/03-vaes.md) โ ELBO in practice
- External: Matrix Cookbook by Petersen & Pedersen โ Comprehensive matrix calculus reference
- External: "Deep Learning" by Goodfellow, Bengio, Courville โ Chapters on optimization and linear algebra Join Discord PreviousInformation TheoryNextBSDA5002 โ Generative AI Foundations