Course contentsShow
← Machine Learning and Deep Learning
Lesson 1582 of 3,53834. Diffusion ModelsFree lesson

Class-Conditional Diffusion

Adding class information to diffusion models through conditional inputs to the noise prediction network.

Class-Conditional Diffusion

What You'll Learn

You'll learn how to guide diffusion models to generate samples from specific classes by feeding class information directly into the denoising network.

The Core Idea

In the previous lesson, you learned that diffusion models can be conditional — they don't have to generate random images, but can be steered toward specific outputs. The simplest and most common form is class-conditional diffusion, where you tell the model which category (class) you want to generate.

Think of it like ordering at a restaurant: instead of saying "bring me any dish" (unconditional), you say "bring me pasta" (conditional on class). The kitchen (diffusion model) still has creative freedom in how it makes pasta, but it knows the category.

How It Works

Class-conditional diffusion adds class information as an additional input to the noise prediction network at each denoising step. Here's the typical approach:

  1. Class embedding: Convert the class label (e.g., "cat" = 3) into a learned vector representation, similar to how words are embedded
  2. Inject into network: Add or concatenate this class embedding with the time embedding before feeding it through the denoising U-Net
  3. Train with labels: During training, randomly sample (image, class_label) pairs and teach the network to denoise conditioned on that class

The network learns: "When denoising at time t for class c, predict this noise pattern."

At generation time, you specify the desired class, and the model generates samples that belong to that category.

Analogy

It's like a sculptor who can make any animal. Instead of randomly choosing, you hand them a card saying "dog" — they still decide the pose, breed, and details, but the output will definitely be a dog.

Key Takeaway: Class-conditional diffusion steers generation by feeding class labels as learned embeddings into the denoising network, enabling controlled generation of specific categories.