Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-274

Matching-Network Cosine

Problem

Classify a query by cosine similarity to a set of support embeddings.

Return [best_index, round(best_similarity, 4)], keeping the smallest index on ties. Zero vectors have similarity 0.0.

Test cases

case 1
in: [[1,0],[[1,0],[0,1],[-1,0]]]
expected: [0,1]
case 2
in: [[0,1],[[1,0],[0.6,0.8]]]
expected: [1,0.8]
case 3
in: [[1,0],[[0,1]]]
expected: [0,0]
Starter codePython
def matching_cosine(query, supports):
    # Your code here
    pass

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