All problems
CLS Classification Head Logits
Problem
Return the logits W x + b for a classification head, where cls_vector is x, weights is one row per class, and bias is one entry per class.
Iterate classes in row order.
Hint
Each class row is a dot product with the pooled vector plus its bias.
Test cases
case 1
in: [[1,2],[[1,0],[0,1]],[0,0]]
expected: [1,2]
case 2
in: [[1,1],[[1,1]],[0.5]]
expected: [2.5]
case 3
in: [[0,0],[[1,2],[-1,-2]],[1,-1]]
expected: [1,-1]
case 4
in: [[],[[1]],[0]]
expected: [0]
Starter codePython
def cls_classification_logits(cls_vector, weights, bias):
# Your code here
pass4 test cases · run your code against them in the editor