Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-343

CLIP Learned Logit Scale

Problem

Compute the CLIP logit scale from its learned parameter.

CLIP parameterizes the temperature as a scalar and uses logit_scale = min(exp(raw_scale), max_scale), where the cap keeps the similarity logits from becoming too sharp (100 in the original implementation). Return the scale rounded to 4 decimal places.

Test cases

case 1
in: [0,100]
expected: 1
case 2
in: [2.302585,100]
expected: 10
case 3
in: [5,100]
expected: 100
case 4
in: [-4.60517,100]
expected: 0.01
Starter codePython
def clip_logit_scale(raw_scale, max_scale):
    # Your code here
    pass

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