Predict x0 from Noise
~10 mincode completion
Implement predict_x0(xt, eps, alpha_bar) returning x0 of the same shape as xt.
Examples
Inverts t1 of the noising problem
- Input
- predict_x0(0.7071067811865476, 0, 0.5)
- Output
- 1
Inverts the pair at abar=0.25
- Input
- predict_x0([0.5, 0.8660254037844386], [0, 1], 0.25)
- Output
- [1, 0]
abar=1, any eps: x0 = xt
- Input
- predict_x0([2, -3], [8, 8], 1)
- Output
- [2, -3]
Hints
Hint 1
Take the square root at the end, not inside the sum.
Hint 2
Do not forget to divide by sqrt alpha bar. That step is easy to skip.
Requirements
alpha_bar: scalar in (0, 1]Return x0, same shape as xt
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Where this shows up
~10 min
••••••••••••••••
8 employers weight this skill
4 autonomy companies, 1 enterprise vendor, 1 defense company, 1 health and bio company, 1 AI product company. Top match scores 87.
Python
import numpy as np
def predict_x0(xt, eps, alpha_bar):
"""
Invert the DDPM closed-form noising step.
Args:
xt, eps: arrays of the same shape
alpha_bar: scalar in (0, 1]
Returns:
x0, same shape as xt
"""
# YOUR CODE HERE
pass