All problems
BYOL-Explore Loss Lite
Problem
Compute the BYOL-style cosine loss 2 - 2 * cos(predicted, target). If either vector has zero norm, return 2.0 as the maximum loss.
Hint
The predictor is trained to match a slowly updated target embedding.
Test cases
case 1
in: [[1,0],[1,0]]
expected: 0
case 2
in: [[1,0],[0,1]]
expected: 2
case 3
in: [[1,1],[1,1]]
expected: 4.440892098500626e-16
case 4
in: [[0,0],[1,0]]
expected: 2
Starter codePython
import math
def byol_explore_loss(predicted, target):
# Your code here
pass4 test cases · run your code against them in the editor