# DDIM v prediction problem

**URL:** <https://discuss.huggingface.co/t/ddim-v-prediction-problem/48234>\
**Category:** 🧨 Diffusers\
**Created:** [July 26, 2023, 12:18pm UTC](https://discuss.huggingface.co/t/ddim-v-prediction-problem/48234 "2023-07-26T12:18:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mostafahaggag](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mostafahaggag](https://discuss.huggingface.co/u/mostafahaggag)\
**Post date:** [July 26, 2023, 12:18pm UTC](https://discuss.huggingface.co/t/ddim-v-prediction-problem/48234/1 "2023-07-26T12:18:25Z")

</div>

Hi community,  
I have checked the DDim scheduler in this code [ddim\_schedular](https://github.com/Max-We/diffusers/blob/fe3cb4261b0104513e69ee143fd7d39614769898/src/diffusers/schedulers/scheduling_ddim.py) and there is something i donot understand in the code that I hoped someone can explain to me why it is done in this way. In line 386, why is he computing the noise in the case of V\_prediciton in this way. The formula used is very different from the one in the paper. Can you please explain to me more why it is done like this? Is there an error or something?

```auto
       elif self.config.prediction_type == "v_prediction":
            pred_original_sample = (alpha_prod_t**0.5) * sample - (beta_prod_t**0.5) * model_output
            pred_epsilon = (alpha_prod_t**0.5) * model_output + (beta_prod_t**0.5) * sample

```

---

<div class="post-metadata">

**Author:** ![hassanpour-huawei](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@hassanpour-huawei](https://discuss.huggingface.co/u/hassanpour-huawei)\
**Post date:** [September 5, 2023, 10:01pm UTC](https://discuss.huggingface.co/t/ddim-v-prediction-problem/48234/2 "2023-09-05T22:01:49Z")

</div>

Velocity is defined as v≡√(α\_t ) ϵ-√(1-α\_t ) x\_0. In this formula, replace x\_0 with its estimation derived from eq. (12) in [[2010.02502] Denoising Diffusion Implicit Models](https://arxiv.org/abs/2010.02502) and solve for ϵ.
