# Lecture 10

## Diffusion Models

Learning to generate by denoising.

2 processes, forward diffusion process that gradually add noise to input and reverse denoising process that learn to generate data by denoising.&#x20;

**Forward**

$$q(x\_t | x\_{t-1}) = N (x\_t; \sqrt{1- \beta\_t}x\_{t-1}, \beta\_tI)$$ -> $$q(x\_{1:T}|x\_0) = \prod\_{t=1}^T q(x\_t|x\_{t-1})$$

**Diffusion Kernel**

define $$\hat{\alpha}\_t = \prod{s=1}^t (1-\beta\_s)$$ -> $$q(x\_t|x\_0) = N(x\_t; \sqrt{\hat{\alpha}\_t}x\_0, (1-\hat{\alpha}\_t)I))$$

For sampling: $$x\_t = \sqrt{\hat{\alpha}\_t}x\_0 + \sqrt{(1-\hat{\alpha}\_t}\epsilon$$ where $$\epsilon \sim N(0, I)$$

$$\beta\_t$$ values schedule is designed such that $$\hat{\alpha}\_t \rightarrow 0$$ and $$q(x\_T|x\_0) \approx N(x\_T; 0, I)$$

<figure><img src="/files/yWWU5bQrKlEohheeUrkx" alt=""><figcaption><p>Forward distribution</p></figcaption></figure>

### Denoising

Generation:

Sample $$x\_T \sim N(x\_T ; 0,I)$$

Iteratively sample $$x\_{t-1} \sim q(x\_{t-1}|x\_t)$$

In general, $$q(x\_{t-1}|x\_t) \propto q(x\_{t-1})q(x\_t|x\_{t-1})$$ is intractable

We can approximate $$q(x\_{t-1}|x\_t)$$ use normal distribution if $$\beta\_t$$ is small each forward diffusion step.

<figure><img src="/files/Mjw080YVqMu52JiyuNB8" alt=""><figcaption><p>Reverse</p></figcaption></figure>

Learning

<figure><img src="/files/urWLXVJD8JsJmBY9mfh2" alt=""><figcaption><p>Learning</p></figcaption></figure>

Parameterization

<figure><img src="/files/WeUEIzl0gueJdjmOwqwn" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/8n7w1Vye1Rae9dtmjcTU" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/g8c6yVWj1V4NerFUPioH" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tianyi0216.gitbook.io/blog/course_notes/cs-839-notes/lecture-10.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
