diffusion icon indicating copy to clipboard operation
diffusion copied to clipboard

Sampling algorithm differ from paper.

Open ariel415el opened this issue 3 years ago • 5 comments

Hi, I want to elaborate on #2: The sampling algorithm in your paper is a bit different that what shown in the paper.

The paper suggests this sample step Screenshot from 2021-05-20 12-36-24

while you do this: Screenshot from 2021-05-20 12-55-28

The clipping is done here https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/diffusion_utils.py#L172

Now I checked and indeed, without the clipping, the two equations are the same. Can you give any interpretation or intuition for the clipping and why it is needed? It seem to be crucial for training while not mentioned in the paper

Thanks

ariel415el avatar May 20 '21 09:05 ariel415el

Is there any update on this? In my experience this detail has been crucial in determining sample quality, yet it seems to be largely unaddressed with regards to diffusion models. Does anyone have any insight on this?

malekinho8 avatar Jul 29 '22 18:07 malekinho8

In https://huggingface.co/blog/annotated-diffusion, the author says:

Note that the code above is a simplified version of the original implementation. We found our simplification (which is in line with Algorithm 2 in the paper) to work just as well as the original, more complex implementation, which employs clipping.

Kaffaljidhmah2 avatar Sep 24 '22 01:09 Kaffaljidhmah2

The issue is that the predictions are often out of range. So the authors are are trying to impose some sort of a correction to get meaningful samples. To do that they are restricting x_reconstructed to -1 to +1 by clipping. So, here is how they generation samples

  1. Get error predictions at step t
  2. Get reconstructed image ie x_recon using error predictions
  3. Clip x_recon since we know x is in range 1 to -1
  4. using clipped x_recon, generate x_t

2 is done using eq Screenshot 2022-10-19 180206

4 is done using Screenshot 2022-10-19 180126

This is a hack and will lead to increased density at 1 and -1

varun-ml avatar Oct 19 '22 12:10 varun-ml

I don't see in the paper the defintion of σt - where is it mentioned and defined? Why do we need to add noise in the reverse process?

ndvbd avatar Jan 24 '23 09:01 ndvbd

I don't see in the paper the defintion of σt - where is it mentioned and defined? Why do we need to add noise in the reverse process?

To make it be a normal distribution.

wanghao-cst avatar Apr 17 '23 05:04 wanghao-cst