# DDIM Inversion when setting prediction\_type = "sample"

**URL:** <https://discuss.huggingface.co/t/ddim-inversion-when-setting-prediction-type-sample/76084>\
**Category:** 🧨 Diffusers\
**Created:** [March 5, 2024, 9:36pm UTC](https://discuss.huggingface.co/t/ddim-inversion-when-setting-prediction-type-sample/76084 "2024-03-05T21:36:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Palawat](https://avatars.discourse-cdn.com/v4/letter/p/43a26b/32.png) [@Palawat](https://discuss.huggingface.co/u/Palawat)\
**Post date:** [March 5, 2024, 9:36pm UTC](https://discuss.huggingface.co/t/ddim-inversion-when-setting-prediction-type-sample/76084/1 "2024-03-05T21:36:46Z")

</div>

I have trained a diffusion model to predict x\_0 instead of predicting noise (follow this paper: [[2303.09556] Efficient Diffusion Training via Min-SNR Weighting Strategy](https://arxiv.org/abs/2303.09556)). Then I would like to use DDIMInverseScheduler(prediction\_type= **“sample”** ) to gradually add noise and then reconstruct the image using DDIMScheduler(prediction\_type= **“sample”** ). One thing that I observed is that in DDIMInverseScheduler from [diffusers/src/diffusers/schedulers/scheduling\_ddim\_inverse.py at main · huggingface/diffusers · GitHub](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddim_inverse.py). At step t=0, they set beta\_prod\_t = 1 - alpha\_prod\_t = 0. So, line 349 is divided by 0 resulting in -inf or inf vector. The figure is shown below.

 ![dividebyzero](https://us1.discourse-cdn.com/hellohellohello/original/3X/d/1/d10d328477bfc2ca3a947585469364dd2217d519.jpeg)

Is there any trick to avoid this issue? Or Is it just theoretically impossible to perform DDIM inversion with the predictive x\_0 network?

Thank you very much
