Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-338

CFG Guided Score

Problem

Mix conditional and unconditional predictions with classifier-free guidance.

The guided value is uncond + scale * (cond - uncond) elementwise, where scale = 1 returns cond and scale = 0 returns uncond. Return the list rounded to 4 decimal places.

Test cases

case 1
in: [[0,0],[1.3,2.5],2]
expected: [2.6,5]
case 2
in: [[0.4,-0.2],[0.9,0.6],1]
expected: [0.9,0.6]
case 3
in: [[0.4,-0.2],[0.9,0.6],0]
expected: [0.4,-0.2]
case 4
in: [[1,2,3],[1,2,3],7.5]
expected: [1,2,3]
Starter codePython
def cfg_guided(uncond, cond, scale):
    # Your code here
    pass

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