All problems
FixMatch Consistency Loss
Problem
Compute the FixMatch consistency loss between strong and weak augmentations.
For pixels whose weak-view maximum probability is at least threshold, compare the strong-view probabilities with the one-hot argmax of the weak view (smallest index on ties). Return the MSE over all selected elements rounded to 4 decimal places, or 0.0 when no pixel passes the threshold.
Test cases
case 1
in: [[[[0.9,0.1],[0.2,0.8]]],[[[0.8,0.2],[0.6,0.4]]],0.7]
expected: 0.01
case 2
in: [[[[0.9,0.1],[0.2,0.8]]],[[[0.3,0.7],[0.6,0.4]]],0.6]
expected: 0.725
case 3
in: [[[[0.5,0.5]]],[[[0.5,0.5]]],0.9]
expected: 0
Starter codePython
def fixmatch_loss(strong, weak, threshold):
# Your code here
pass3 test cases · run your code against them in the editor