yang-song / score_sde_pytorch

PyTorch implementation for Score-Based Generative Modeling through Stochastic Differential Equations (ICLR 2021, Oral)
https://arxiv.org/abs/2011.13456
Apache License 2.0
1.58k stars 295 forks source link

Question about Eq. (4) and VP SDE implementation #44

Open SuwoongHeo opened 1 year ago

SuwoongHeo commented 1 year ago

Hi,

In the paper, the sampling equation of VP SDE (=: DDPM) differs from the DDPM's form. Specifically, the multiplicand to the score function is defined as $\beta_i$ while DDPM uses $(1-\alpha_t)/(\sqrt{1-\bar{\alpha_t}})$. It seems that the code in the repo originally intended to use $\bar{\alpha_t}$ since it is initialized (but not used) as can be seen in the below snippet. Can you provide me reason for this difference?

https://github.com/yang-song/score_sde_pytorch/blob/cb1f359f4aadf0ff9a5e122fe8fffc9451fd6e44/sde_lib.py#L127

prithuls commented 9 months ago

Hi, I am just starting to work on this repo code. I noticed the authors defined different loss functions. If we are to use DDPM loss function, we would need self.alphas_cumprod that you mentioned. If you check the following lines, i.e. https://github.com/yang-song/score_sde_pytorch/blob/cb1f359f4aadf0ff9a5e122fe8fffc9451fd6e44/losses.py#L138

This self.sqrt_1m_alphas_cumprod has been later used in losses.py to get DDPM loss function i.e. https://github.com/yang-song/score_sde_pytorch/blob/cb1f359f4aadf0ff9a5e122fe8fffc9451fd6e44/losses.py#L138.

P.S. I am not sure why the loss SDE function is that way though.