PIXELBANKv9.1.0
Menu

Problem Statement

Continuous-time diffusion (VDM) parameterizes everything by lambda_t = log SNR_t. Convert an alpha_bar schedule to its log-SNR curve.

Background

The signal-to-noise ratio is SNR_t = alpha_bar_t / (1 - alpha_bar_t), and its log is

λt=log⁡SNRt=log⁡αˉt−log⁡(1−αˉt)\lambda_t = \log \text{SNR}_t = \log \bar{\alpha}_t - \log(1 - \bar{\alpha}_t)

lambda runs from large positive (clean) to large negative (pure noise) and is the natural axis for noise schedules and loss weights.

Your Task

Implement:

def log_snr(alpha_bar):

Return the list of lambda_t values rounded to 4 decimals.

Input Format

  • alpha_bar: list of cumulative products, each strictly in (0, 1).

Output Format

  • A list of floats rounded to 4 decimals.

Sample

print(log_snr([0.5, 0.2]))

Output:

[0.0, -1.3863]

Example:

Input:
print(log_snr([0.5, 0.2]))
Output:
[0.0, -1.3863]
Reasoning:
  • For the first element αˉ1=0.5\bar{\alpha}_1 = 0.5, calculate the log-SNR using the formula λ1=log⁡(0.5)−log⁡(1−0.5)\lambda_1 = \log(0.5) - \log(1 - 0.5). Since log⁡(0.5)≈−0.6931\log(0.5) \approx -0.6931 and log⁡(0.5)≈−0.6931\log(0.5) \approx -0.6931, the difference is −0.6931−(−0.6931)=0.0-0.6931 - (-0.6931) = 0.0.
  • For the second element αˉ2=0.2\bar{\alpha}_2 = 0.2, calculate λ2=log⁡(0.2)−log⁡(1−0.2)\lambda_2 = \log(0.2) - \log(1 - 0.2). This simplifies to log⁡(0.2)−log⁡(0.8)\log(0.2) - \log(0.8), which is equivalent to log⁡(0.2/0.8)=log⁡(0.25)\log(0.2 / 0.8) = \log(0.25).
  • Evaluating the logarithm for the second element yields log⁡(0.25)≈−1.386294\log(0.25) \approx -1.386294.
  • Round both calculated values to 4 decimal places: 0.00.0 remains 0.00.0, and −1.386294-1.386294 rounds to −1.3863-1.3863.
  • The final output is [0.0, -1.3863]

Constraints:

  • 1 <= len(alpha_bar) <= 100000, values strictly in (0, 1).
  • lambda_t = log(alpha_bar_t) - log(1 - alpha_bar_t).
  • 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.
Log-SNR of a Schedule - Easy | PixelBank