Giter VIP home page Giter VIP logo

Comments (5)

summmeer avatar summmeer commented on May 27, 2024

Hi,
the q_sample() can work for t=0, which returns x_start. The model learns the mse loss between $x_0$ and $Emb(w^x)$ here.

from diffuseq.

skpig avatar skpig commented on May 27, 2024

Sorry, but I still don't understand why q_sample() returns x_start when t=0.

x_t = self.q_sample(x_start, t, noise=noise, mask=input_ids_mask) # reparametrization trick.

The param x_start here equals to x_start_mean + self.sqrt_one_minus_alphas_cumprod[0] * noise (according to self._get_x_start()). So it stands for $x_0 = Emb(w) + \beta_0\times noise$ in your paper.

def q_sample(self, x_start, t, noise=None, mask=None):
"""
Diffuse the data for a given number of diffusion steps.
In other words, sample from q(x_t | x_0).
:param x_start: the initial data batch.
:param t: the number of diffusion steps (minus 1). Here, 0 means one step.
:param noise: if specified, the split-out normal noise.
:param mask: anchoring masked position
:return: A noisy version of x_start.
"""
if noise is None:
noise = th.randn_like(x_start)
assert noise.shape == x_start.shape
x_t = (
_extract_into_tensor(self.sqrt_alphas_cumprod, t, x_start.shape) * x_start
+ _extract_into_tensor(self.sqrt_one_minus_alphas_cumprod, t, x_start.shape)
* noise
)
if mask == None:
return x_t
else:
mask = th.broadcast_to(mask.unsqueeze(dim=-1), x_start.shape)
return th.where(mask==0, x_start, x_t)

Now dig into the q_sample() function.
The return variable x_t equals to self.sqrt_alphas_cumprod[0] * x_start + self.sqrt_one_minus_alphas_cumprod[0] * noise. So it stands for $x_t = \alpha_0 x_0 + \beta_0\times noise$. I don't know what the return value x_t stands for.

from diffuseq.

summmeer avatar summmeer commented on May 27, 2024

Hi,
Sorry for the ambiguity, let me elucidate. For canonical noise scheduler, $\beta_0 \rightarrow 0$, so it returns $x_0$. However, we use the sqrt noise scheduler, where $\beta_0=0.121$ when $T=2000$. The model learns the mse loss between $\alpha_0 x_0 + \beta_0 * noise$ and $Emb(w^x) + \beta_0 * noise$, so the statement above still holds.

from diffuseq.

skpig avatar skpig commented on May 27, 2024

Sorry, but I cannot deduce your conclusion from your code.

The model learns the mse loss between α0x0+β0∗noise and Emb(wx)+β0∗noise

Please give me a hint based on some code links. Again, thank you for your patience!

from diffuseq.

LetianY avatar LetianY commented on May 27, 2024

Hi! I got a similar question regarding the quoted lines.

It seems to me that model_out_x_start=model_output since we are not predicting the noise term. In addition, we are not using pred_xprev. In this case, why we bother to use the helper function _x0_helper?

Thanks!

from diffuseq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.