lucidrains / denoising-diffusion-pytorch

Implementation of Denoising Diffusion Probabilistic Model in Pytorch
MIT License
7.86k stars 987 forks source link

Question related to DDIM #220

Open Mostafa-Haggag opened 1 year ago

Mostafa-Haggag commented 1 year ago

I had a question in denoising_diffusion_pytorch.py why in ddim_sample we sample till step -1. shouldnot we just return the output returned from the DDIM equation at step 0, why do we use it again to predict a new x_start and this x_start is returned? Thanks, Mostafa

Luh1124 commented 1 year ago

I have a similar doubt. It seems that the author does not directly use the sampling process provided by DDPM in the code. image Instead, the mean of $x{t-1}$ is calculated using this formula.image Then use the Reparameterization Trick to obtain $x {t-1}$

Luh1124 commented 1 year ago

You can refer to https://zhuanlan.zhihu.com/p/569994589 for a detailed derivation of DDPM, and the same applies to DDIM.

Mostafa-Haggag commented 1 year ago

Hi, Thank you so much for your answer. I really appreciate it. I think maybe i was not clear in my quesiton. In the line 690 In Denoising_diffusionmodel_pytorch. Why do this extra step and pass it through model and not directly returning the return of equation at line 703 directly? Why the time pairs are up to (0,-1). I do not know if I am clear but the DDIM sampler paper mentions that you should not be doing this. Under the assumption that I am predicting X_0 directly image I shared a lin of code to make sure that I am more clear.