v-Target from x0 and Noise
Problem Statement
The v-prediction target (Salimans & Ho, 2022) is a signal/noise-balanced combination. Compute it from x0 and eps.
Background
The velocity target is
It equals eps at high noise and -x0 at low noise, which is what makes v-prediction stable across the whole schedule and the default for progressive distillation.
Your Task
Implement:
def v_target(x0, eps, alpha_bar):
Return v as a list rounded to 4 decimals.
Input Format
- x0, eps: lists of equal length D.
- alpha_bar (float) in (0, 1).
Output Format
- A list of D floats rounded to 4 decimals.
Sample
print(v_target([1.0, 0.0], [0.0, 1.0], 0.25))
Output:
[-0.866, 0.5]
Example
print(v_target([1.0, 0.0], [0.0, 1.0], 0.25))
[-0.866, 0.5]
- Compute the scaling coefficients for the noise and signal components using : the noise weight is and the signal weight is .
- Calculate the v-prediction target for the first element (, ) by combining the weighted terms: .
- Calculate the v-prediction target for the second element (, ) using the same weights: .
- Round each result to 4 decimal places to satisfy the output format, yielding and .
- The final output is [-0.866, 0.5]
Constraints
len(x0) == len(eps),0 < alpha_bar < 1.v = sqrt(alpha_bar)*eps - sqrt(1 - alpha_bar)*x0.- Round to 4 decimals; avoid
-0.0.