PIXELBANKv9.1.0
Menu

Min-SNR Weights for v-Prediction

Problem Statement

Min-SNR weighting changes form with the prediction target. For v-prediction the effective weight uses SNR + 1 in the denominator. Compute it.

Background

Hang et al. give the Min-SNR weight per parameterization by dividing the clamped SNR by the parameterization's implicit weight:

  • eps-pred: w = min(SNR, gamma) / SNR
  • x0-pred: w = min(SNR, gamma)
  • v-pred: w = min(SNR, gamma) / (SNR + 1)

The SNR + 1 denominator for v reflects that v-prediction already balances signal and noise, so its baseline weight is SNR + 1.

Your Task

Implement:

def min_snr_v_weights(snr, gamma):

Return the list of v-prediction Min-SNR weights rounded to 4 decimals.

Input Format

  • snr: list of non-negative SNRs.
  • gamma (float): the clamp.

Output Format

  • A list of floats rounded to 4 decimals.

Sample

print(min_snr_v_weights([10.0, 4.0, 1.0], 5.0))

Output:

[0.4545, 0.8, 0.5]

Example:

Input:
print(min_snr_v_weights([10.0, 4.0, 1.0], 5.0))
Output:
[0.4545, 0.8, 0.5]
Reasoning:
  • For each SNR value, the weight is calculated using the v-prediction formula: w=min⁡(SNR,γ)SNR+1w = \frac{\min(\text{SNR}, \gamma)}{\text{SNR} + 1}. The numerator clamps the SNR to the maximum value γ\gamma to prevent weights from becoming too large, while the denominator accounts for the signal-to-noise ratio plus one, specific to v-prediction.
  • For the first input SNR=10.0\text{SNR} = 10.0 with γ=5.0\gamma = 5.0, the numerator is min⁡(10.0,5.0)=5.0\min(10.0, 5.0) = 5.0 and the denominator is 10.0+1=11.010.0 + 1 = 11.0. The weight is 5.0/11.0≈0.4545455.0 / 11.0 \approx 0.454545, which rounds to 0.45450.4545.
  • For the second input SNR=4.0\text{SNR} = 4.0 with γ=5.0\gamma = 5.0, the numerator is min⁡(4.0,5.0)=4.0\min(4.0, 5.0) = 4.0 and the denominator is 4.0+1=5.04.0 + 1 = 5.0. The weight is 4.0/5.0=0.84.0 / 5.0 = 0.8, which remains 0.80.8 when rounded to 4 decimals.
  • For the third input SNR=1.0\text{SNR} = 1.0 with γ=5.0\gamma = 5.0, the numerator is min⁡(1.0,5.0)=1.0\min(1.0, 5.0) = 1.0 and the denominator is 1.0+1=2.01.0 + 1 = 2.0. The weight is 1.0/2.0=0.51.0 / 2.0 = 0.5, which remains 0.50.5 when rounded to 4 decimals.
  • The final output is [0.4545, 0.8, 0.5]

Constraints:

  • 1 <= len(snr) <= 100000, all snr[i] >= 0, gamma > 0.
  • w_t = min(SNR_t, gamma) / (SNR_t + 1).
  • Round to 4 decimals.
🔒

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.