Skip to content
DeepForgeby svx
All problems
HardComputer Visioncv-339

CFG Variance Rescale

Problem

Rescale a guided prediction to match the conditional prediction's standard deviation (CFG rescaling).

Compute the population standard deviations of cond and guided, then multiply guided elementwise by std_cond / std_guided, rounded to 4 decimal places. If the guided deviation is zero, return guided rounded unchanged.

Test cases

case 1
in: [[1,-1],[3,0]]
expected: [2,0]
case 2
in: [[2,0],[1,1]]
expected: [1,1]
case 3
in: [[0,0,0],[5,-5,5]]
expected: [0,0,0]
case 4
in: [[1,2,3],[2,4,6]]
expected: [1,2,3]
Starter codePython
def cfg_rescale(cond, guided):
    # Your code here
    pass

4 test cases · run your code against them in the editor