From a2d6e805a6bde7e576c1a3b1594c7fea36ddef8a Mon Sep 17 00:00:00 2001 From: Varuna Jayasiri Date: Tue, 7 Nov 2023 09:13:19 +0000 Subject: [PATCH] fix beta expression in ddpm docs --- docs/diffusion/ddpm/evaluate.html | 60 ++++++++++++++--------------- labml_nn/diffusion/ddpm/evaluate.py | 4 +- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/docs/diffusion/ddpm/evaluate.html b/docs/diffusion/ddpm/evaluate.html index f15aeb75..70cdfd6d 100644 --- a/docs/diffusion/ddpm/evaluate.html +++ b/docs/diffusion/ddpm/evaluate.html @@ -149,7 +149,7 @@ -

+

@@ -197,7 +197,7 @@ -

+

@@ -210,7 +210,7 @@ #

To calculate

-

@@ -244,7 +244,7 @@ M834 80h400000v40h-400000z">

+

@@ -256,7 +256,7 @@ M834 80h400000v40h-400000z">

@@ -403,8 +403,8 @@ M834 80h400000v40h-400000z"> -

We sample an image step-by-step using and at each step show the estimate

We sample an image step-by-step using and at each step show the estimate

+M834 80h400000v40h-400000z">ϵθ(xt,t))

@@ -438,7 +438,7 @@ M834 80h400000v40h-400000z">

+

@@ -510,7 +510,7 @@ M834 80h400000v40h-400000z">

+

@@ -538,7 +538,7 @@ M834 80h400000v40h-400000z">

+

Sample from

@@ -564,9 +564,9 @@ M834 80h400000v40h-400000z"> and -

We get and .

-

Then interpolate to

-

Then get

+

We get and .

+

Then interpolate to

+

Then get

@@ -622,7 +622,7 @@ M834 80h400000v40h-400000z">

+

@@ -695,7 +695,7 @@ M834 80h400000v40h-400000z">

+

@@ -707,7 +707,7 @@ M834 80h400000v40h-400000z">

+

@@ -745,7 +745,7 @@ M834 80h400000v40h-400000z">

+

@@ -757,7 +757,7 @@ M834 80h400000v40h-400000z">

+

@@ -807,7 +807,7 @@ M834 80h400000v40h-400000z"> +

Sample an image using

@@ -884,7 +884,7 @@ M834 80h400000v40h-400000z">

+

@@ -921,7 +921,7 @@ M834 80h400000v40h-400000z"> +

Sample from

+M834 80h400000v40h-400000z">βtϵθ(xt,t))
236    def p_sample(self, xt: torch.Tensor, t: torch.Tensor, eps_theta: torch.Tensor):
@@ -1024,7 +1024,7 @@ c5.3,-9.3,12,-14,20,-14 H400000v40H845.2724 s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7 c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z -M834 80h400000v40h-400000z">βtϵθ(xt,t))

+M834 80h400000v40h-400000z">βtϵθ(xt,t))

@@ -1095,7 +1095,7 @@ c5.3,-9.3,12,-14,20,-14 H400000v40H845.2724 s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7 c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z -M834 80h400000v40h-400000z">ϵθ(xt,t))

+M834 80h400000v40h-400000z">ϵθ(xt,t))

@@ -1141,7 +1141,7 @@ c5.3,-9.3,12,-14,20,-14 H400000v40H845.2724 s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7 c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z -M834 80h400000v40h-400000z">ϵθ(xt,t))

+M834 80h400000v40h-400000z">ϵθ(xt,t))

diff --git a/labml_nn/diffusion/ddpm/evaluate.py b/labml_nn/diffusion/ddpm/evaluate.py index 5ec37bbb..52251b61 100644 --- a/labml_nn/diffusion/ddpm/evaluate.py +++ b/labml_nn/diffusion/ddpm/evaluate.py @@ -57,10 +57,10 @@ class Sampler: # q(x_{t-1}|x_t, x_0) &= \mathcal{N} \Big(x_{t-1}; \tilde\mu_t(x_t, x_0), \tilde\beta_t \mathbf{I} \Big) \\ # \tilde\mu_t(x_t, x_0) &= \frac{\sqrt{\bar\alpha_{t-1}}\beta_t}{1 - \bar\alpha_t}x_0 # + \frac{\sqrt{\alpha_t}(1 - \bar\alpha_{t-1})}{1-\bar\alpha_t}x_t \\ - # \tilde\beta_t &= \frac{1 - \bar\alpha_{t-1}}{a} + # \tilde\beta_t &= \frac{1 - \bar\alpha_{t-1}}{1 - \bar\alpha_t} \beta_t # \end{align} - # $\tilde\beta_t$ + # $$\tilde\beta_t = \frac{1 - \bar\alpha_{t-1}}{1 - \bar\alpha_t} \beta_t$$ self.beta_tilde = self.beta * (1 - alpha_bar_tm1) / (1 - self.alpha_bar) # $$\frac{\sqrt{\bar\alpha_{t-1}}\beta_t}{1 - \bar\alpha_t}$$ self.mu_tilde_coef1 = self.beta * (alpha_bar_tm1 ** 0.5) / (1 - self.alpha_bar)