Diffusion playgroundLaboratorio della diffusione

A cloud of points in the plane is turned into a standard Gaussian by adding noise in \(T\) small steps, and a small network is trained in the page to predict, from a noisy point and the time, the noise that was added; since that prediction is, up to a factor, the score \(\nabla \log p_t\) of the noisy data, running the steps backwards from pure noise and removing at each step the predicted noise carries the points back onto the shape. Hover the parts of the two formulas to see them in the planes below them.

Una nuvola di punti nel piano è trasformata in una gaussiana standard aggiungendo rumore in \(T\) piccoli passi, e una piccola rete è addestrata nella pagina a prevedere, da un punto rumoroso e dal tempo, il rumore che è stato aggiunto; poiché quella previsione è, a meno di un fattore, lo score \(\nabla \log p_t\) dei dati rumorosi, percorrendo i passi all'indietro a partire da rumore puro e togliendo a ogni passo il rumore previsto si riportano i punti sulla forma. Passa sulle parti delle due formule per vederle nei piani sottostanti.

The forward process at the time \(t\) of the slider: every point of the data (2000 of them) with its own fixed noise \(\varepsilon\), and therefore moving the slider moves each point along a line. Below, the two coefficients against \(t\), violet \(\sqrt{\bar\alpha_t}\) and gold \(\sqrt{1-\bar\alpha_t}\).Il processo in avanti al tempo \(t\) del cursore: ogni punto dei dati (2000 in tutto) con il proprio rumore fisso \(\varepsilon\), e quindi, se sposti il cursore, ogni punto si muove lungo una retta. Sotto, i due coefficienti in funzione di \(t\), in viola \(\sqrt{\bar\alpha_t}\) e in oro \(\sqrt{1-\bar\alpha_t}\).

\(x_t = \class{p-sig}{\sqrt{\bar\alpha_t}}\;\class{p-x0}{x_0} + \class{p-noi}{\sqrt{1-\bar\alpha_t}}\;\class{p-eps}{\varepsilon},\quad \varepsilon \sim \mathcal N(0, I)\)

The field learned by the network at the time \(t\) of the slider: at each point of a grid the arrow is \(-\sqrt{1-\bar\alpha_t}\, \varepsilon_\theta(x, t) = (1-\bar\alpha_t)\,\nabla\log p_t(x)\), the move toward the expected \(\sqrt{\bar\alpha_t}\,x_0\), with the length compressed (square root of the length, the longest arrow one cell); the data in grey underneath.Il campo appreso dalla rete al tempo \(t\) del cursore: in ogni punto di una griglia la freccia è \(-\sqrt{1-\bar\alpha_t}\, \varepsilon_\theta(x, t) = (1-\bar\alpha_t)\,\nabla\log p_t(x)\), lo spostamento verso il valore atteso di \(\sqrt{\bar\alpha_t}\,x_0\), con la lunghezza compressa (la radice quadrata della lunghezza, la freccia più lunga pari a una cella); sotto, i dati in grigio.

The reverse process: 600 points drawn from \(\mathcal N(0, I)\) at \(t = T\) follow the steps of the sampler down to \(t = 0\), with the trails of 40 of them; the data in grey. Hover the formula to see, for the last step, where the points were, the move given by the network and the fresh noise; with DDIM there is no fresh noise, and \(s\) is the next time of the sampler (\(t-1\), or \(t - T/20\) with 20 steps).Il processo inverso: 600 punti estratti da \(\mathcal N(0, I)\) a \(t = T\) seguono i passi del campionatore fino a \(t = 0\), con le tracce di 40 di essi; i dati in grigio. Passa sulla formula per vedere, per l'ultimo passo, dove si trovavano i punti, lo spostamento dato dalla rete e il rumore nuovo; con DDIM non c'è rumore nuovo, e \(s\) è il tempo successivo del campionatore (\(t-1\), o \(t - T/20\) con 20 passi).

\(x_{t-1} = \frac{1}{\sqrt{\alpha_t}}\Big(\class{p-xt}{x_t} - \class{p-drift}{\frac{\beta_t}{\sqrt{1-\bar\alpha_t}}\,\varepsilon_\theta(x_t, t)}\Big) + \class{p-z}{\sigma_t z}\)

The loss \(\frac1B\sum_i \|\varepsilon_\theta(x_{t_i}, t_i) - \varepsilon_i\|^2\) of every batch (\(B = 128\), \(t_i\) uniform in \(1, \dots, T\)), faint, and its moving average; it does not go to zero, since the noise cannot be told apart from the data at large \(t\). Below, the distance of the last samples from the data.La loss \(\frac1B\sum_i \|\varepsilon_\theta(x_{t_i}, t_i) - \varepsilon_i\|^2\) di ogni batch (\(B = 128\), \(t_i\) uniforme in \(1, \dots, T\)), tenue, e la sua media mobile; non va a zero, poiché a \(t\) grande il rumore non si può distinguere dai dati. Sotto, la distanza degli ultimi campioni dai dati.