Noise is random variation added to data. In a diffusion model, it is not an accidental flaw: adding it gradually breaks down an image’s structure, and learning to remove it provides a way to generate new images. The forward process adds noise; the reverse process starts from noise and restores structure step by step. section 10.3 section 10.10
A noise schedule controls each forward step. At timestep t, beta determines how much of the previous data is retained and how much random noise is added: xₜ = √(1 − βₜ)xₜ₋₁ + √βₜ ε. A linear schedule increases beta over time. The process can also be computed directly from the original data at a chosen timestep using cumulative products of 1 − beta. section 10.5
def diffuse_points(points, beta):
new_mean = torch.sqrt(1-beta) * points
noise = torch.randn(points.shape)
perturbation = torch.sqrt(beta) * noise
points = new_mean + perturbation
return points, noise
This PyTorch function makes one forward step with torch.randn noise and returns that noise alongside the changed points. section 10.5
Watch a pattern disappear
Start with 2D points arranged as a PyTorch logo. Add scheduled noise to one point to see how it moves, then diffuse every point. Across 1,000 steps, the original pattern becomes unrecognizable. section 10.5
To learn the reverse process, a neural network receives noisy data and its timestep and predicts the noise used to produce it. Training compares that prediction with the actual noise using mean squared error. During generation, repeated predictions guide the removal of noise from an initially noisy sample. section 10.6 section 10.6.1
def get_loss(model, x, t):
x_noisy, noise = forward_diffusion_sample(x, t) #1
noise_pred = model(x_noisy, t) #2
return F.mse_loss(noise, noise_pred) #3
The loss function creates a noisy sample, predicts its noise, and measures mean squared error against the noise actually added. section 10.6.1
Noise can also serve a different purpose: data augmentation. Random Gaussian noise added to a CT training sample creates a variation of that sample. As with other augmentations, the result should still be representative of the original training case. section 14.6.1
Listing 14.17 Adding random Gaussian noise
if 'noise' in augmentation_dict: noise_t = torch.randn_like(augmented_chunk) noise_t *= augmentation_dict['noise'] augmented_chunk += noise_t
This augmentation generates noise with torch.randn_like, scales it by a configured amount, and adds it to the CT chunk. section 14.6.1










