Project-MONAI / GenerativeModels

MONAI Generative Models makes it easy to train, evaluate, and deploy generative models and related applications
Apache License 2.0
555 stars 78 forks source link

446 Fix the way reversed_step in DDIM treats the first alpha in alphas_cumprod #452

Closed matanat closed 6 months ago

matanat commented 6 months ago

In reversed_step, when traversing the timesteps all the way to the last, an exception is raised by exceeding the boundaries of the alphas_cumprod. This is now fixed by setting the first value of the alphas_cumprod to either zero or to the second-to-last element. The behavior is set by the init argument set_alpha_to_one which control the behavior regarding the first element in the array. Also, names of local variables in the function are fixed.

Linked to: issue 446

matanat commented 6 months ago

Not sure about using the same set_alpha_to_one init argument for this. On the other hand, creating another argument to control this seems like an overkill and changing the name of the existing argument might break existing code.