Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-293

Prototypical Loss

Problem

Compute the prototypical network loss for one query.

Distances are squared Euclidean to each prototype; logits are -distance / temperature and the loss is the negative log softmax probability of the true class. Round to 4 decimal places.

Test cases

case 1
in: [[0,0],[[0,0],[10,0]],0,1]
expected: 0
case 2
in: [[0,0],[[0,0],[10,0]],1,1]
expected: 100
case 3
in: [[1,1],[[0,0],[2,2]],0,2]
expected: 0.6931
Starter codePython
def prototypical_loss(query, prototypes, label, temperature):
    # Your code here
    pass

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