v9.1.1
Menu

v-Target from x0 and Noise

easyPROParameterizations and the Reverse PosteriorDiffusion ModelsDiffusion Models 1

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

v=αˉ ε−1−αˉ x0v = \sqrt{\bar{\alpha}}\, \varepsilon - \sqrt{1 - \bar{\alpha}}\, x_0

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

Input
print(v_target([1.0, 0.0], [0.0, 1.0], 0.25))
Output
[-0.866, 0.5]
Reasoning
  • Compute the scaling coefficients for the noise and signal components using αˉ=0.25\bar{\alpha} = 0.25: the noise weight is 0.25=0.5\sqrt{0.25} = 0.5 and the signal weight is 1−0.25=0.75≈0.8660\sqrt{1 - 0.25} = \sqrt{0.75} \approx 0.8660.
  • Calculate the v-prediction target for the first element (x0=1.0x_0 = 1.0, ϵ=0.0\epsilon = 0.0) by combining the weighted terms: v0=0.5⋅0.0−0.8660⋅1.0=−0.8660v_0 = 0.5 \cdot 0.0 - 0.8660 \cdot 1.0 = -0.8660.
  • Calculate the v-prediction target for the second element (x0=0.0x_0 = 0.0, ϵ=1.0\epsilon = 1.0) using the same weights: v1=0.5⋅1.0−0.8660⋅0.0=0.5v_1 = 0.5 \cdot 1.0 - 0.8660 \cdot 0.0 = 0.5.
  • Round each result to 4 decimal places to satisfy the output format, yielding −0.866-0.866 and 0.50.5.
  • 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.

Learn this in

More from Diffusion Models 1

PRO

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test results

Sign in to run your code against the test cases.