Answers.Body: <p>The key intuition I think is that high dimensional standard normals have almost constant length <span class="math-container">$\sqrt{n}$</span> due to Law of Large Numbers. And also, random high dimensional vectors are perpendicular to each other (unlike 2D where two random unit vectors are 30 degrees apart). Thus, repeated sampling gives us points that are efficiently spread out on a hollow ball of constant radius. I think the denoising NN really uses these regularities to find structure in the image set.</p>
  <p>What I’m am imagining is this:</p>
  <ol>
  <li><p>Every image in the library is a vector in a high dimensional space. The tips are leaves of an unknown tree. We’ve to identify the tree. (The tree is imaginary and helps me think. I will get rid of it later.)</p>
  </li>
  <li><p>By repeatedly adding small orthogonal constant norm noise to the tips, we are adding little balls to the tips.</p>
  </li>
  <li><p>Imagine you cut off all the portions of the tree inside these balls. Now you’ve fewer branch tips cuz the finer branchings are all gone. The NN basically identifies these fewer tips. Ie, fed a point on the ball around a final leaf, the NN will give the tip or fewer new point(s) that are common to all the nearby leaves.</p>
  </li>
  <li><p>Now take the truncated tree and attach relatively bigger balls at the new tips. Cut the tree again within these balls. You’ve still fewer tips which the NN learns cuz it knows this is a different size ball. Note that I can get similar results by successively adding balls to balls to the original leaves and cutting the tree all at once.</p>
  </li>
  <li><p>You do this with bigger and bigger balls. Suppose the final step causes the NN to learn, say 3 tips that are the ends the now very diminished tree.</p>
  </li>
  <li><p>To generate, start with a point on a unit ball. Knowing the scale, the NN will try to push it towards on of the three stumps and then up the tree towards the finer stumps and so on.</p>
  </li>
  <li><p>Basically this way of thinking takes the library image set as points in the n dimensional space. The NN reduces dimensions by finding fewer points that are close to the original points within successive balls of various radii. The orthogonality and constant norm of high dimensional random vectors makes it super easy to generate these balls. And the NN structure is highly suited to find common points within these balls.</p>
  </li>
  <li><p>Ball with larger norms means more nonzero pixels ie broad brush features. Balls with smaller norms means few nonzero pixels ie minute detail. So training happens in any order by successively adding multiple balls in one step, but reconstruction is sequential from large ball to small.</p>
  </li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-01T02:28:22.137Z
Answers.LastActivityDate: 2023-08-01T02:35:45.947Z
Answers.LastEditDate: 2023-08-01T02:35:45.947Z
Answers.UserDisplayName: Venky Nagar
Body: <p>I'm reading the Denoising Diffusion Probabilistic Models paper (Ho et al. 2020). And I am puzzled about the training objective. I understood (I think) the trick regarding the reparametrization of the variance in terms of the noise:</p>
  <p><span class="math-container">$$\mu_\theta(x_t, t) = \frac{1}{\sqrt{\alpha_t}}\left(x_t - \frac{\beta_t}{\sqrt{1 - \bar{\alpha_t}}}\epsilon_\theta(x_t, t)\right)$$</span></p>
  <p>But what I do not understand fully is the training objective:</p>
  <p><span class="math-container">$$\nabla_\theta\lVert \epsilon - \epsilon_\theta\left(\sqrt{\bar{\alpha}}x_0 + \sqrt{1- \bar{\alpha}_t}\epsilon, t \right) \rVert$$</span></p>
  <p>It looks to me like <span class="math-container">$\epsilon$</span> led from <span class="math-container">$x_0 \rightarrow x_t$</span>, so it is unclear how learning to predict this noise actually forces the model to learn to undo the forward process from <span class="math-container">$x_{t-1} \rightarrow x_t$</span> only.
  The sampling instead is very clear.</p>
  <hr />
  <p>The same question arose while reading another paper that uses a different formulation to build a diffusion generative model over graphs. In the paper &quot;DiGress&quot; (Vignac et al 2023), they define a discrete version of the forward process for application to graphs <span class="math-container">$G=(X, E), \space X \in \mathbb{R}^{n \times a}, \space E \in \mathbb{R}^{n \times n \times b}
  $</span>. Sampling is done by a categorical distribution defined by matrices:
  <span class="math-container">$$[Q_X^t]_{ij} = q(x^t = i | x ^ {t - 1} = i) \\
  [Q_E^t]_{ij} = q(e^t = i | e ^ {t - 1} = i) \\
  \bar{Q}^t_X = Q^1_X...Q^t_X\\
  \bar{Q}^t_E = Q^1_E...Q^t_E$$</span></p>
  <p>and
  <span class="math-container">$$q(G^t| G^{t-1})=(X^{t-1}Q^t_X, E^{t-1}Q^t_E) \space\text{and}\space q(G^t| G)=(X\bar{Q}^t_X, E\bar{Q}^t_E)$$</span></p>
  <p>The main difference here, besides the forward distributions to be categorical, is the fact that the model is required to compute the probabilities of the categorical distributions directly: <span class="math-container">$p_\theta^G=(p^X_\theta, p^E_\theta)$</span>. And the loss is computed by comparing the predicted probabilities of the model against the <em>original</em> graph.</p>
  <p><span class="math-container">$$
  \nabla_\theta\left( \sum_{l\leq i\leq n} \text{cross-entropy}(x_i,p_{i \space \theta}^{X}) + \sum_{l\leq i,j\leq n} \text{cross-entropy}(e_{ij},p_{ij \space \theta}^{E})\right)
  $$</span></p>
  <p>My doubt is, here as well, how can it be correct that the model predicts directly the distribution of the original graph and still somehow this process should be equivalent to predicting <em>only</em> the backward to the timestep <span class="math-container">$t-1$</span>, as in all diffusion models.</p>
  
Tags: <generative-model><diffusion-models><evidence-lower-bound><latent-variable>
Title: Clarification on the training objective of denoising diffusion models
UserDisplayName: user3903647
ThreadText: # Clarification on the training objective of denoising diffusion models
  
  (Asked by: username_0 on 2023-04-21)
  
  I'm reading the Denoising Diffusion Probabilistic Models paper (Ho et al. 2020). And I am puzzled about the training objective. I understood (I think) the trick regarding the reparametrization of the variance in terms of the noise:
  
  $$\mu\_\theta(x\_t, t) = \frac{1}{\sqrt{\alpha\_t}}\left(x\_t - \frac{\beta\_t}{\sqrt{1 - \bar{\alpha\_t}}}\epsilon\_\theta(x\_t, t)\right)$$
  
  But what I do not understand fully is the training objective:
  
  $$\nabla\_\theta\lVert \epsilon - \epsilon\_\theta\left(\sqrt{\bar{\alpha}}x\_0 + \sqrt{1- \bar{\alpha}\_t}\epsilon, t \right) \rVert$$
  
  It looks to me like $\epsilon$ led from $x\_0 \rightarrow x\_t$, so it is unclear how learning to predict this noise actually forces the model to learn to undo the forward process from $x\_{t-1} \rightarrow x\_t$ only.
  The sampling instead is very clear.
  
  ---
  
  The same question arose while reading another paper that uses a different formulation to build a diffusion generative model over graphs. In the paper "DiGress" (Vignac et al 2023), they define a discrete version of the forward process for application to graphs $G=(X, E), \space X \in \mathbb{R}^{n \times a}, \space E \in \mathbb{R}^{n \times n \times b}
  $. Sampling is done by a categorical distribution defined by matrices:
  $$[Q\_X^t]\_{ij} = q(x^t = i | x ^ {t - 1} = i) \\
  [Q\_E^t]\_{ij} = q(e^t = i | e ^ {t - 1} = i) \\
  \bar{Q}^t\_X = Q^1\_X...Q^t\_X\\
  \bar{Q}^t\_E = Q^1\_E...Q^t\_E$$
  
  and
  $$q(G^t| G^{t-1})=(X^{t-1}Q^t\_X, E^{t-1}Q^t\_E) \space\text{and}\space q(G^t| G)=(X\bar{Q}^t\_X, E\bar{Q}^t\_E)$$
  
  The main difference here, besides the forward distributions to be categorical, is the fact that the model is required to compute the probabilities of the categorical distributions directly: $p\_\theta^G=(p^X\_\theta, p^E\_\theta)$. And the loss is computed by comparing the predicted probabilities of the model against the *original* graph.
  
  $$
  \nabla\_\theta\left( \sum\_{l\leq i\leq n} \text{cross-entropy}(x\_i,p\_{i \space \theta}^{X}) + \sum\_{l\leq i,j\leq n} \text{cross-entropy}(e\_{ij},p\_{ij \space \theta}^{E})\right)
  $$
  
  My doubt is, here as well, how can it be correct that the model predicts directly the distribution of the original graph and still somehow this process should be equivalent to predicting *only* the backward to the timestep $t-1$, as in all diffusion models.
  
  **Tags:** generative-model, diffusion-models, evidence-lower-bound, latent-variable
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-08-01. Score: 0
  
  The key intuition I think is that high dimensional standard normals have almost constant length $\sqrt{n}$ due to Law of Large Numbers. And also, random high dimensional vectors are perpendicular to each other (unlike 2D where two random unit vectors are 30 degrees apart). Thus, repeated sampling gives us points that are efficiently spread out on a hollow ball of constant radius. I think the denoising NN really uses these regularities to find structure in the image set.
  
  What I’m am imagining is this:
  
  1. Every image in the library is a vector in a high dimensional space. The tips are leaves of an unknown tree. We’ve to identify the tree. (The tree is imaginary and helps me think. I will get rid of it later.)
  2. By repeatedly adding small orthogonal constant norm noise to the tips, we are adding little balls to the tips.
  3. Imagine you cut off all the portions of the tree inside these balls. Now you’ve fewer branch tips cuz the finer branchings are all gone. The NN basically identifies these fewer tips. Ie, fed a point on the ball around a final leaf, the NN will give the tip or fewer new point(s) that are common to all the nearby leaves.
  4. Now take the truncated tree and attach relatively bigger balls at the new tips. Cut the tree again within these balls. You’ve still fewer tips which the NN learns cuz it knows this is a different size ball. Note that I can get similar results by successively adding balls to balls to the original leaves and cutting the tree all at once.
  5. You do this with bigger and bigger balls. Suppose the final step causes the NN to learn, say 3 tips that are the ends the now very diminished tree.
  6. To generate, start with a point on a unit ball. Knowing the scale, the NN will try to push it towards on of the three stumps and then up the tree towards the finer stumps and so on.
  7. Basically this way of thinking takes the library image set as points in the n dimensional space. The NN reduces dimensions by finding fewer points that are close to the original points within successive balls of various radii. The orthogonality and constant norm of high dimensional random vectors makes it super easy to generate these balls. And the NN structure is highly suited to find common points within these balls.
  8. Ball with larger norms means more nonzero pixels ie broad brush features. Balls with smaller norms means few nonzero pixels ie minute detail. So training happens in any order by successively adding multiple balls in one step, but reconstruction is sequential from large ball to small.
  
  
  ---
  
  