CS180 Project 5 — Part B

Flow Matching from Scratch

Part 1 — Single-step Denoising UNet

In Part 1, we train a UNet denoiser on MNIST with Gaussian noise and evaluate it under different noise levels.

1.2.1 — Training a Denoiser (σ = 0.5)

Train a UNet denoiser on MNIST with noise level σ = 0.5. Below are the training loss curve and sample denoising results.

Training Loss Curve

1.2.1 training loss curve

Sample Results (Epoch 1)

1.2.1 epoch 1 results

Sample Results (Epoch 5)

1.2.1 epoch 5 results

1.2.2 — Out-of-Distribution Testing

We test the denoiser (trained at σ = 0.5) on a fixed test image while varying σ ∈ [0.0, 0.2, 0.4, 0.5, 0.6, 0.8, 1.0].

1.2.2 OOD denoising grid

1.2.3 — Denoising Pure Noise

We train a denoiser to map pure Gaussian noise z ~ N(0, I) into clean MNIST digits. Below are the training curve and samples after epoch 1 and 5.

Training Loss Curve

1.2.3 training loss curve

Samples (Epoch 1)

1.2.3 epoch 1 samples

Samples (Epoch 5)

1.2.3 epoch 5 samples

Part 2 — Flow Matching Model

In Part 2, we train a time-conditioned UNet to predict the flow field for iterative denoising, then extend it to class conditioning with classifier-free guidance (CFG).

2.2 — Training the Time-Conditioned UNet

Train a time-conditioned UNet using flow matching. Below is the training loss curve over the full training process.

2.2 training loss curve

2.3 — Sampling from the Time-Conditioned UNet

Samples produced via iterative denoising after 1, 5, and 10 epochs.

Epoch 1

2.3 epoch 1 samples

Epoch 5

2.3 epoch 5 samples

Epoch 10

2.3 epoch 10 samples

2.5 — Training the Class-Conditioned UNet

Train the class-conditioned UNet with classifier-free dropout (p_uncond = 0.1). Below is the training loss curve.

2.5 class-conditioned training loss

2.6 — Class-Conditional Sampling with CFG (γ = 5.0)

Generate 4 instances of each digit (0–9) using classifier-free guidance with γ = 5.0, shown after 1, 5, and 10 epochs.

Epoch 1

2.6 epoch 1 CFG samples

Epoch 5

2.6 epoch 5 CFG samples

Epoch 10

2.6 epoch 10 CFG samples