Lecture 25 · Neural Radiance Fields

Deep Unsupervised Learning · Lecture 25。个人学习讲义与配套实验,按主题整理并持续修订。

课程源码 ZIP ↓

个人整理的学习笔记,非官方讲义;课程来源与整理说明见课程介绍。配套示例未逐一运行验证。

本篇目录

Maps to: UC Berkeley CS294-158 Deep Unsupervised Learning (Spring 2024), Lecture 13b · Thu 4/18/2024 · Neural Radiance Fields (guest lecture: Ben Mildenhall). Basis: The slide link on the course page is broken (it returns an error page), so this lecture is written from the papers. These are the work of the guest speaker and his collaborators and of the line of research the talk is known to cover:

  • Core method: NeRF (Mildenhall et al., ECCV 2020) and Fourier features (Tancik et al., NeurIPS 2020).
  • Extensions: mip-NeRF (Barron et al., ICCV 2021), Instant-NGP (Müller et al., 2022), 3D Gaussian splatting (Kerbl et al., 2023).
  • Generative 3-D: GRAF (Schwarz et al., 2020), Dream Fields (Jain et al., 2022) and DreamFusion (Poole et al., 2022).

The code builds an analytic 3-D scene whose true images are known from every viewpoint, so every rendering error is exact. It then:

  • renders the scene by volume rendering;
  • measures spectral bias and positional encoding;
  • trains tiny NeRFs from 4–32 views;
  • makes a 3-D field from 2-D information alone by score distillation with an exact denoiser.

Code: code/lecture25/ (4 scripts + nerf.py; PyTorch on CPU; script 03 trains 7 NeRFs on the first run, everything else takes minutes) Reading time: 2.5 hours including running the code


0. How to read this lecture

0.1 Learning goals

After this lecture you should be able to:

  1. Volume rendering. Derive the volume rendering integral and NeRF’s quadrature (alpha compositing). Explain transmittance, weights, expected depth, and stratified and hierarchical sampling.
  2. Positional encoding. Explain spectral bias and why coordinate networks need a positional encoding or Fourier features. Choose the encoding’s bandwidth.
  3. NeRF. Describe NeRF’s architecture and training, what view dependence buys, and why few views are hard. Place mip-NeRF, Instant-NGP and Gaussian splatting.
  4. Generative 3-D. Explain how a generative model of 3-D can come from 2-D: GRAF’s adversarial NeRF, Dream Fields’ CLIP loss, and DreamFusion’s score distillation. Explain the Janus problem and why view-dependent conditioning fixes it.

0.2 Prerequisites and scope

AssumedIntroduced hereElsewhere
Lecture 11–12 (diffusion, denoisers, exact denoisers, score distillation through a 2-D renderer in Lecture 12)volume rendering, positional encoding, NeRF—
Lecture 15 / 22 (CLIP)GRAF, Dream Fields, DreamFusion, the Janus problem
Basic projective geometry (pinhole camera)

0.3 Map

§1  novel-view synthesis: why a neural field
§2  volume rendering: the integral, its quadrature, sampling               ← code 01
§3  spectral bias and positional encoding                                ← code 02
§4  NeRF: architecture, training, views, and what came next              ← code 03
§5  generative 3-D: GRAF, Dream Fields, DreamFusion and score distillation ← code 04
§6  summary   §7 pitfalls   §8 exercises   §9 further reading   §10 the end of the course

0.4 Notation

symbolmeaning
r(t)=o+td\mathbf{r}(t) = \mathbf{o} + t\mathbf{d}a ray from camera center o\mathbf{o} in unit direction d\mathbf{d}
σ(x)≥0\sigma(\mathbf{x}) \ge 0volume density
c(x,d)∈[0,1]3\mathbf{c}(\mathbf{x}, \mathbf{d}) \in [0, 1]^3emitted color
T(t)T(t)transmittance
wiw_icompositing weights
PSNR−10log⁡10MSE-10\log_{10}\mathrm{MSE} in dB, for images in [0,1][0, 1]

1. Novel-view synthesis: why a neural field?

Given photos of a scene from known cameras, render it from a new camera. This problem goes back decades, through several representations:

  • light fields (densely sampled rays);
  • image-based rendering (warp nearby photos);
  • multi-plane images;
  • voxel grids (memory grows as resolution³).

NeRF’s idea (Mildenhall et al., 2020): represent the scene as a continuous function FΘ:(x,d)↦(σ,c)F_\Theta : (\mathbf{x}, \mathbf{d}) \mapsto (\sigma, \mathbf{c}), an MLP. Render it with differentiable volume rendering, and fit the MLP so that its renderings reproduce the photos. Three properties matter:

  1. Compact. A few MB of weights instead of a dense voxel grid.
  2. Continuous. Query at any resolution, without a grid.
  3. Differentiable end to end. The only supervision needed is the photos and their camera poses (estimated by structure-from-motion, e.g. COLMAP).

In this course’s language, NeRF is not a generative model: it over-fits one scene. It enters a course on unsupervised learning because it is the representation that 3-D generative models build on (§5).


2. Volume rendering

2.1 The integral

Model the scene as a cloud of particles with density σ(x)\sigma(\mathbf{x}): the probability of a ray being stopped in [t,t+dt][t, t + dt] is σ(r(t)) dt\sigma(\mathbf{r}(t))\,dt. The probability that the ray travels from the camera to tt without being stopped is the transmittance: T(t)=exp⁡(−∫tntσ(r(s)) ds).T(t) = \exp\Big(-\int_{t_n}^{t} \sigma(\mathbf{r}(s))\,ds\Big).

This follows from dT=−σT dtdT = -\sigma T\,dt. The expected color of the ray is C(r)=∫tntfT(t) σ(r(t)) c(r(t),d) dt  +  T(tf) cbg,C(\mathbf{r}) = \int_{t_n}^{t_f} T(t)\,\sigma(\mathbf{r}(t))\,\mathbf{c}(\mathbf{r}(t), \mathbf{d})\,dt \;+\; T(t_f)\, \mathbf{c}_{\text{bg}}, a probability-weighted average of the colors where the ray stops, plus the background if it never stops.

2.2 The quadrature: alpha compositing

Split the ray at depths t1<⋯<tNt_1 < \dots < t_N with gaps δi=ti+1−ti\delta_i = t_{i+1} - t_i, and assume σ\sigma and c\mathbf{c} are constant in each interval. Within interval ii the ray is stopped with probability αi=1−e−σiδi.\alpha_i = 1 - e^{-\sigma_i \delta_i}. Integrating exactly under that assumption gives C^=∑i=1NTi αi ci,Ti=∏j<i(1−αj),wi=Tiαi.\hat{C} = \sum_{i=1}^{N} T_i\,\alpha_i\,\mathbf{c}_i, \qquad T_i = \prod_{j < i}(1 - \alpha_j), \qquad w_i = T_i \alpha_i.

This is front-to-back alpha compositing of semi-transparent slabs, the “over” operator of computer graphics. It is differentiable in every σi\sigma_i and ci\mathbf{c}_i. The same weights give an expected depth ∑iwiti/∑iwi\sum_i w_i t_i / \sum_i w_i and an opacity ∑iwi\sum_i w_i for free.

One ray, measured (script 01, Part 1). The center pixel of a view hits the red sphere. Density rises from 0 to ~15 between depths 2.97 and 3.43. The weights peak at 0.228 near depth 3.13, where the ray enters the solid, and vanish behind it (TT falls to 0.002): occlusion falls out of the formula. The pixel’s opacity is 0.998, its expected depth 3.166. Compositing front-to-back and back-to-front gives the same color, to 2×10−72 \times 10^{-7}.

2.3 How many samples? (Part 2)

Here is how the quadrature converges, measured as PSNR against a 1,024-sample reference (4 views, 32 × 32):

samples per rayuniform midpointsstratified (one draw)hierarchical (n/2+n/2n/2 + n/2)
819.718.219.1
1627.624.132.7
3238.034.541.3
6447.944.248.1
12854.251.354.3
25660.758.260.2
  • Midpoints of equal bins converge fastest for a fixed scene but always query the same depths.
  • Stratified sampling (one random depth per bin, NeRF’s choice for training) is slightly worse for one image. But over training the network is queried at every depth, so it learns a continuous field instead of the field’s values at fixed depths.
  • Hierarchical sampling spends a second batch of samples by inverse-transform sampling the first pass’s weights: where the ray actually hits something. It is the most accurate at a small budget (16–32 samples). NeRF trains a “coarse” and a “fine” network this way.

3. Spectral bias and positional encoding

An MLP fed raw coordinates (x,y,z)(x, y, z) learns smooth functions. Deep networks fit low frequencies first and high frequencies only slowly (spectral bias, Rahaman et al. 2019). Fine geometry and texture are exactly the high frequencies.

The fix: NeRF maps each coordinate through γ(p)=(p, sin⁡(20πp),cos⁡(20πp),…,sin⁡(2L−1πp),cos⁡(2L−1πp)),\gamma(p) = \big(p,\, \sin(2^0\pi p), \cos(2^0\pi p), \dots, \sin(2^{L-1}\pi p), \cos(2^{L-1}\pi p)\big), with L=10L = 10 for positions and L=4L = 4 for directions.

Why it works (Tancik et al., 2020). In the neural-tangent-kernel limit, an MLP on γ(x)\gamma(\mathbf{x}) behaves like kernel regression with a stationary kernel k(x−x′)k(\mathbf{x} - \mathbf{x}') whose bandwidth is set by the encoding’s frequencies.

  • Random Fourier features [sin⁡(2πBx),cos⁡(2πBx)][\sin(2\pi B\mathbf{x}), \cos(2\pi B\mathbf{x})] with B∼N(0,σ2)B \sim \mathcal{N}(0, \sigma^2) make that bandwidth one tunable knob.
  • Too small σ\sigma: blurry.
  • Too large σ\sigma: the kernel is so narrow that the network interpolates noise between training points.

Measured (script 02). Part 1 fits a 1-D target ∑ksin⁡(2πkx+ϕk)\sum_k \sin(2\pi k x + \phi_k) with k∈{1,4,16,48}k \in \{1, 4, 16, 48\}. The table gives the residual amplitude per frequency (1 = nothing learned):

inputstepsfreq 1freq 4freq 16freq 48
raw xx1000.050.810.991.00
raw xx3000.010.010.920.99
raw xx30000.010.030.690.93
NeRF encoding, 8 frequencies1000.000.000.000.01
Fourier features, σ=16\sigma = 161000.000.000.000.00

On raw xx, frequency 1 is fitted within 100 steps and frequency 4 within 300. Frequencies 16 and 48 are still 69% and 93% unfitted after 3,000 steps: spectral bias, measured. With either encoding, every component is fitted within 100 steps.

Part 2 regresses a 64 × 64 rendering from (x,y)(x, y), training on 25% of the pixels (every other row and column):

input encodinginput dimtrain PSNRheld-out PSNR
raw (x,y)(x, y)235.932.4
NeRF encoding, 4 frequencies1859.633.6
NeRF encoding, 8 frequencies3463.614.5
Fourier features, σ=1\sigma = 125663.537.0
Fourier features, σ=4\sigma = 425674.431.6
Fourier features, σ=16\sigma = 1625663.19.6
Fourier features, σ=64\sigma = 6425650.29.3

The rendering is simple (flat colored solids), so raw coordinates already reach 32.4 dB on held-out pixels, with blurred edges. The best encoding is Fourier features with σ=1\sigma = 1 (37.0 dB).

The informative failures are at the top of the frequency range. Encodings with frequencies the training grid cannot determine fit the training pixels almost perfectly but alias in between: 8 NeRF frequencies give 14.5 dB, σ=16\sigma = 16 and 6464 give 9.6 and 9.3. With every other pixel given, a frequency above 32 cycles per image is invisible in the data, and the network fills it with anything.

The encoding’s bandwidth must match both the signal and the sampling. NeRF’s 10 frequencies suit dozens of dense, overlapping views (and mip-NeRF’s integrated encoding damps the frequencies a pixel cannot resolve).


4. NeRF

4.1 The model and its training

NeRF’s MLP has eight 256-wide layers, with a skip connection.

  • The density σ\sigma depends on position only.
  • The color depends on position and viewing direction: a feature vector is concatenated with γ(d)\gamma(\mathbf{d}). This lets a surface look different from different angles (specular highlights) while keeping the geometry view-independent.

Training. Each step samples a batch of rays from all training images and renders them with the coarse and fine passes. It minimizes ∑∥C^(r)−C(r)∥2\sum \lVert \hat{C}(\mathbf{r}) - C(\mathbf{r})\rVert^2. There is no 3-D supervision of any kind.

Cost. The original NeRF needed a day of GPU time per scene.

4.2 Measured (script 03)

A tiny NeRF (4 × 128 MLP, 6 frequencies, 48 stratified samples per ray, 1,500 steps of 1,024 rays). Images are 32 × 32, the cameras sit on a ring at two elevations, and there are 7 held-out views:

training viewsPSNR, training viewsPSNR, 7 novel viewsdepth error, novel views
447.38.41.329
842.336.60.017
1642.239.20.014
3241.841.10.014

Four views are not enough. The NeRF reproduces its 4 training views almost perfectly (47.3 dB) and is useless anywhere else (8.4 dB, depth off by 1.3 units). With nothing constraining the space between 90°-apart cameras, the optimization finds some density that explains each photo separately: a per-scene fit with no prior has no reason to find the scene.

From 8 views on, novel views are almost as good as training views (36.6 → 41.1 dB), and the rendered depth is right to 0.014 units. The gap between training and novel PSNR shrinks as views are added, the signature of over-fitting disappearing. This is why few-view NeRF needs priors (pixelNeRF, RegNeRF, diffusion priors).

Ablations with 16 views:

modelPSNR, training viewsPSNR, novel viewsdepth error
positional encoding (6 frequencies), 48 samples42.239.20.014
no positional encoding (raw x,y,zx, y, z)34.634.10.109
+ view-dependent color (direction encoded)42.139.40.015
hierarchical sampling, 24 coarse + 24 fine41.938.70.015
  • Without positional encoding the NeRF is blurry: 34.1 dB, and depth errors 8× larger. Spectral bias again, now in 3-D.
  • View-dependent color changes nothing here (39.4 vs 39.2 dB): our scene’s colors do not depend on the viewing direction, so the extra input has nothing to explain. In real scenes it captures specular highlights.
  • Hierarchical sampling with the same total budget (24 + 24) does not beat 48 stratified samples on this compact scene (38.7 dB). Its advantage, which script 01 showed for the quadrature, matters when the scene occupies a small part of a long ray, as in real captures with distant backgrounds.

4.3 What came next (context)

  • mip-NeRF (Barron et al., 2021) renders cones instead of rays. It encodes a whole Gaussian region of space with an integrated positional encoding (high frequencies are damped where the cone is wide), which removes aliasing across scales. Zip-NeRF combines this with grids.
  • Instant-NGP (Müller et al., 2022) replaces most of the MLP with a multiresolution hash table of learned features: a positional encoding that is learned per scene. Training drops from a day to seconds.
  • 3D Gaussian splatting (Kerbl et al., 2023) drops the neural field. It optimizes millions of explicit 3-D Gaussians with colors and opacities, and rasterizes them by alpha compositing, the same formula as §2.2, sorted by depth. It renders in real time.
  • Few-view and generalizable NeRFs (pixelNeRF, RegNeRF and others) add priors learned across scenes. That is where NeRF meets this course’s generative models.

5. Generative 3-D

A NeRF fits one scene from many posed photos. A generative 3-D model should produce new scenes, ideally learned from 2-D images only, since 3-D data are scarce. Three routes:

GRAF / π-GAN / EG3D (adversarial). The generator is a NeRF conditioned on a latent code (shape and appearance). Its renderings from random cameras go to a 2-D GAN discriminator that compares them with real photos (Lectures 9–10). Multi-view consistency is built in, because every image is a rendering of one 3-D field. EG3D makes this efficient with a tri-plane representation.

Dream Fields (CLIP). Optimize one NeRF so that its renderings from random cameras have a high CLIP score for a caption, plus a transparency penalty. Lecture 22 showed that pixel-level CLIP guidance makes adversarial patterns. The NeRF’s 3-D structure and the augmentations are what keep Dream Fields’ renderings reasonable.

DreamFusion (score distillation). Use a pretrained text-to-image diffusion model as the critic. For a rendering x=g(θ,camera)\mathbf{x} = g(\theta, \text{camera}):

  1. noise it: xt=αtx+σtϵ\mathbf{x}_t = \alpha_t \mathbf{x} + \sigma_t \boldsymbol\epsilon;
  2. let the diffusion model predict the noise, ϵ^(xt;y,t)\hat{\boldsymbol\epsilon}(\mathbf{x}_t; y, t);
  3. update the NeRF along ∇θLSDS=Et,ϵ[w(t) (ϵ^(xt;y,t)−ϵ) ∂x∂θ].\nabla_\theta \mathcal{L}_{\text{SDS}} = \mathbb{E}_{t, \boldsymbol\epsilon}\Big[w(t)\,\big(\hat{\boldsymbol\epsilon}(\mathbf{x}_t; y, t) - \boldsymbol\epsilon\big)\,\frac{\partial \mathbf{x}}{\partial \theta}\Big].

The diffusion model’s Jacobian is dropped, which is why it is cheap. Up to that approximation, this is the gradient of a weighted sum over noise levels of KL(q(xt∣x) ∥ p(xt∣y))\mathrm{KL}\big(q(\mathbf{x}_t \mid \mathbf{x}) \,\|\, p(\mathbf{x}_t \mid y)\big): it pushes every rendering toward images the prior finds likely (Lecture 12 used the same gradient on a 2-D superellipse renderer).

The Janus problem. A text-to-image prior does not know which view it is looking at. Most training images of “a dog” show its face, so SDS pushes every view toward a face, producing multi-faced objects. DreamFusion’s fix is view-dependent prompting: append “front view” / “side view” / “back view” to the prompt according to the camera’s azimuth.

Measured (script 04). The prior is the exact optimal denoiser of a finite set of images, the 24 true views of the scene at 16 × 16 (Lecture 11’s exact denoisers: E[x0∣xt]\mathbb{E}[\mathbf{x}_0 \mid \mathbf{x}_t] is a softmax-weighted average of the set’s images). A small NeRF is trained from scratch, three ways (3 seeds):

how the field is trainedPSNR vs the true view at that azimuthPSNR vs the closest of the 24 images
reconstruction (posed images, photometric loss)33.4 ± 0.333.4
SDS, view-conditioned prior (images within ±15° of the camera)27.6 ± 1.227.6
SDS, view-agnostic prior (all 24 images)15.7 ± 0.118.3

Which image does the render at each azimuth resemble most (seed 0)?

render azimuth0306090120150180210240270300330
reconstruction0306090120150180210240270300330
SDS, view-conditioned0306090120150180210240270300330
SDS, view-agnostic195195255195255255255195195255195195
  • Score distillation creates a 3-D field from a purely 2-D prior. No camera was ever paired with a target image. With the view-conditioned prior, every render resembles the true view of its own azimuth (27.6 dB, 6 dB short of reconstruction from posed images).
  • The view-agnostic prior gives the Janus problem in an extreme form. The field became rotationally symmetric: a dark band of mixed colors on the floor disk that looks the same from every camera (figure 04_sds.png). By PSNR its renders are closest to the views from 195° and 255° wherever the camera is, but they are poor copies even of those (18.3 dB). Every camera is pulled toward some image of the set, and the only 3-D field that can satisfy “look like a typical image from every side” is one that looks alike from every side. With a text-to-image prior, whose typical image of an animal shows its face, the same pull produces the familiar multi-faced objects.

The SDS gradient is mode-seeking (Exercise 5): it pulls each render toward whichever prior image is nearest, not toward the one that belongs to the camera. Conditioning the prior on the view, DreamFusion’s “front / side / back view” prompts, is what makes the 3-D object consistent.


6. Summary

  1. Volume rendering turns a density and color field into pixels by alpha compositing along rays: C^=∑iTiαici\hat{C} = \sum_i T_i\alpha_i\mathbf{c}_i. It is differentiable, handles occlusion automatically, and gives depth and opacity for free. The quadrature converged to 41 dB at 32 samples with hierarchical sampling.
  2. Spectral bias makes MLPs on raw coordinates blurry. On raw input, frequency 16 was still 69% unfitted after 3,000 steps; with an encoding, everything was fitted in 100. Positional encodings and Fourier features fix this, but their bandwidth must match the signal and the sampling: 9–15 dB held-out with too many frequencies, 37 dB at the right scale.
  3. NeRF fits one scene from posed photos. Ours reached 39–41 dB on novel views from 16–32 views, and failed completely from 4 (8.4 dB) despite a near-perfect fit of those 4. Without positional encoding: 34 dB. Successors made it anti-aliased (mip-NeRF), fast (Instant-NGP) and real-time (Gaussian splatting).
  4. Generative 3-D comes from 2-D models: GRAF (a GAN over renderings), Dream Fields (CLIP), DreamFusion (score distillation). SDS with an exact view-conditioned prior built a consistent 3-D field from no paired data (27.6 dB). A view-agnostic prior produced a field that looks alike from every side (15.7 dB): the Janus problem, cured by conditioning the prior on the view.

7. Common pitfalls

  1. Too few samples per ray, or a fixed grid of depths. Both alias. Stratify during training, and use hierarchical sampling to spend samples where the weights are.
  2. Raw coordinates into an MLP. The result is blurry (spectral bias). Encode them, but match the encoding’s bandwidth to the data: too many frequencies alias between training samples.
  3. Few or badly posed views. NeRF is a per-scene optimization with no prior. With few views it fits the training photos and hallucinates the rest; with wrong camera poses nothing is consistent.
  4. Expecting a NeRF to be a generative model. It reproduces one scene; generation needs a latent code with a learned distribution (GRAF) or an external prior (SDS).
  5. Score distillation with a view-agnostic prior. Every view is pushed toward the prior’s most typical image, producing Janus objects. Condition the prior on the camera.
  6. Confusing a soft density with hard surfaces. A density field accumulates opacity before the surface (our scene’s solids look slightly “fat”). Surface-based variants (NeuS, VolSDF) control this.

8. Exercises

Exercise 1 (transmittance — derivation). From “the probability of being stopped in [t,t+dt][t, t + dt] is σ(t) dt\sigma(t)\,dt”, derive T(t)=exp⁡(−∫0tσ)T(t) = \exp(-\int_0^t \sigma). Show that ∫0∞T(t)σ(t) dt=1−T(∞)\int_0^\infty T(t)\sigma(t)\,dt = 1 - T(\infty).

Answer

Transmittance. T(t+dt)=T(t)(1−σ(t) dt)T(t + dt) = T(t)(1 - \sigma(t)\,dt), so T′=−σTT' = -\sigma T and T(t)=exp⁡(−∫0tσ)T(t) = \exp(-\int_0^t \sigma) with T(0)=1T(0) = 1.

The integral. Tσ=−T′T\sigma = -T', so ∫0∞Tσ dt=T(0)−T(∞)=1−T(∞)\int_0^\infty T\sigma\,dt = T(0) - T(\infty) = 1 - T(\infty). The weights of a pixel sum to its opacity, and the remaining T(∞)T(\infty) is the background’s share.

Exercise 2 (the quadrature is exact for piecewise-constant fields — derivation). Show that if σ\sigma and c\mathbf{c} are constant on each interval [ti,ti+1)[t_i, t_{i+1}), the integral equals ∑iTiαici\sum_i T_i \alpha_i \mathbf{c}_i exactly.

Answer

On interval ii, T(t)=Tie−σi(t−ti)T(t) = T_i e^{-\sigma_i (t - t_i)}. Then ∫titi+1Tσici dt=Tici(1−e−σiδi)=Tiαici,\int_{t_i}^{t_{i+1}} T\sigma_i \mathbf{c}_i\,dt = T_i \mathbf{c}_i \big(1 - e^{-\sigma_i \delta_i}\big) = T_i \alpha_i \mathbf{c}_i, and Ti+1=Tie−σiδi=Ti(1−αi)T_{i+1} = T_i e^{-\sigma_i\delta_i} = T_i(1 - \alpha_i). Summing over intervals gives the formula. The only approximation is treating the field as piecewise constant, hence the convergence in §2.3.

Exercise 3 (front-to-back = back-to-front — derivation). Show that Cback←αici+(1−αi)CbackC_{\text{back}} \leftarrow \alpha_i \mathbf{c}_i + (1 - \alpha_i) C_{\text{back}} applied from i=Ni = N down to 1 (starting from the background) gives the same color as the front-to-back sum.

Answer

Unroll the recursion: C=α1c1+(1−α1)[α2c2+(1−α2)[… ]]=∑i[∏j<i(1−αj)]αici+∏j(1−αj) cbg.C = \alpha_1 \mathbf{c}_1 + (1 - \alpha_1)\big[\alpha_2 \mathbf{c}_2 + (1 - \alpha_2)[\dots]\big] = \sum_i \Big[\prod_{j<i}(1 - \alpha_j)\Big]\alpha_i \mathbf{c}_i + \prod_j (1 - \alpha_j)\, \mathbf{c}_{\text{bg}}. These are exactly TiαiT_i \alpha_i and TN+1T_{N+1}. Script 01 matches the two orders to 2×10−72 \times 10^{-7}.

Exercise 4 (Fourier features as a kernel — derivation). For γ(x)=[cos⁡(2πBx),sin⁡(2πBx)]\gamma(\mathbf{x}) = [\cos(2\pi B\mathbf{x}), \sin(2\pi B\mathbf{x})], show that γ(x)⊤γ(x′)=∑jcos⁡(2πbj⊤(x−x′))\gamma(\mathbf{x})^\top \gamma(\mathbf{x}') = \sum_j \cos(2\pi \mathbf{b}_j^\top(\mathbf{x} - \mathbf{x}')). Conclude that the kernel is stationary and that its width shrinks as σ\sigma grows when bj∼N(0,σ2I)\mathbf{b}_j \sim \mathcal{N}(0, \sigma^2 I).

Answer

Stationarity. cos⁡acos⁡b+sin⁡asin⁡b=cos⁡(a−b)\cos a \cos b + \sin a \sin b = \cos(a - b) with a=2πbj⊤xa = 2\pi\mathbf{b}_j^\top\mathbf{x} and b=2πbj⊤x′b = 2\pi\mathbf{b}_j^\top\mathbf{x}'. The result depends only on x−x′\mathbf{x} - \mathbf{x}': the kernel is stationary.

Width. In expectation over b∼N(0,σ2I)\mathbf{b} \sim \mathcal{N}(0, \sigma^2 I), Ecos⁡(2πb⊤u)=exp⁡(−2π2σ2∥u∥2)\mathbb{E}\cos(2\pi\mathbf{b}^\top\mathbf{u}) = \exp(-2\pi^2\sigma^2\lVert\mathbf{u}\rVert^2): a Gaussian kernel of width ∝1/σ\propto 1/\sigma. A large σ\sigma means each training point influences only a tiny neighbourhood, so between training points the prediction is unconstrained (script 02’s aliasing).

Exercise 5 (SDS — derivation). Show that if the prior were a single image x∗\mathbf{x}^* (the denoiser returns x^0=x∗\hat{\mathbf{x}}_0 = \mathbf{x}^*), the SDS update with w(t)=σtw(t) = \sigma_t moves the rendering x\mathbf{x} along αt(x∗−x)\alpha_t(\mathbf{x}^* - \mathbf{x}) in expectation.

Answer

ϵ^=(xt−αtx∗)/σt=(αtx+σtϵ−αtx∗)/σt\hat{\boldsymbol\epsilon} = (\mathbf{x}_t - \alpha_t\mathbf{x}^*)/\sigma_t = (\alpha_t\mathbf{x} + \sigma_t\boldsymbol\epsilon - \alpha_t\mathbf{x}^*)/\sigma_t, so σt(ϵ^−ϵ)=αt(x−x∗).\sigma_t(\hat{\boldsymbol\epsilon} - \boldsymbol\epsilon) = \alpha_t(\mathbf{x} - \mathbf{x}^*). Gradient descent therefore moves x\mathbf{x} toward x∗\mathbf{x}^* with step αt\alpha_t.

With a finite set, x∗\mathbf{x}^* is replaced by a posterior-weighted average of the set’s images. At low noise that average collapses to the image nearest to x\mathbf{x}: SDS is mode-seeking. With a view-agnostic set, the nearest image need not be the view of the current camera, hence the Janus result.

Exercise 6 (coding). In script 04, widen the view-conditioned window from ±15° to ±45°. Predict the effect on “PSNR vs the true view”, then run it.

Answer

(Run it.) A wider window lets each camera be pulled toward images taken up to 45° away, so the views blur together and start to disagree. Expect consistency to degrade between the ±15° result and the view-agnostic one.


9. Further reading

  • B. Mildenhall, P. Srinivasan, M. Tancik, J. Barron, R. Ramamoorthi, R. Ng. NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis, ECCV 2020.
  • M. Tancik et al. Fourier Features Let Networks Learn High Frequency Functions in Low Dimensional Domains, NeurIPS 2020; N. Rahaman et al. On the Spectral Bias of Neural Networks, ICML 2019.
  • J. Barron et al. Mip-NeRF (ICCV 2021), Mip-NeRF 360 (CVPR 2022), Zip-NeRF (ICCV 2023).
  • T. Müller et al. Instant Neural Graphics Primitives with a Multiresolution Hash Encoding, SIGGRAPH 2022.
  • B. Kerbl et al. 3D Gaussian Splatting for Real-Time Radiance Field Rendering, SIGGRAPH 2023.
  • K. Schwarz et al. GRAF (NeurIPS 2020); E. Chan et al. π-GAN (CVPR 2021), EG3D (CVPR 2022).
  • A. Jain et al. Zero-Shot Text-Guided Object Generation with Dream Fields, CVPR 2022.
  • B. Poole, A. Jain, J. Barron, B. Mildenhall. DreamFusion: Text-to-3D using 2D Diffusion, ICLR 2023.
  • J. Kajiya, B. Von Herzen. Ray Tracing Volume Densities, SIGGRAPH 1984; N. Max. Optical Models for Direct Volume Rendering, 1995 (the rendering equation used here).
  • P. Wang et al. NeuS (2021); L. Yariv et al. VolSDF (2021) — densities derived from signed distance functions.

10. The end of the course

This was the last lecture. The course went from 1-D histograms (Lecture 2) to:

  • autoregressive models, flows, VAEs, GANs and diffusion (Lectures 3–12), each measured against the exact distribution of ShapeWorld;
  • self-supervised representations (Lectures 13–15);
  • large language and video models (Lectures 16–17);
  • semi-supervised learning and unsupervised alignment (18–19);
  • compression, where likelihood becomes a file size (20–21);
  • multimodal models and the systems that train them (22–23);
  • two frontiers (24–25).

One thread ran through all of it: a model of the data is a measurable object, whether as bits per example, as samples that are valid or not, or as features that make the world’s factors explicit. Where the truth was known, every claim could be checked, and many of the checks surprised us. The “plan vs reality” section of every README records them.

← 返回课程目录