PIXELBANKv9.1.0
Menu

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

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.
πŸ”’

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

0/0
Run code to see test results.