All problems
Soft Dice Loss
Problem
Compute the soft Dice loss between a probability map and a binary target.
Return 1 - (2 * sum(p * t) + eps) / (sum(p) + sum(t) + eps), rounded to 4 decimal places. eps guards against division by zero.
Test cases
case 1
in: [[[0.8,0.2]],[[1,0]],0]
expected: 0.2
case 2
in: [[[1,0]],[[1,0]],0.000001]
expected: 0
case 3
in: [[[0.5]],[[1]],0.000001]
expected: 0.3333
case 4
in: [[[0.9,0.1],[0.1,0.9]],[[1,0],[0,1]],0]
expected: 0.1
Starter codePython
def soft_dice_loss(prob, target, eps):
# Your code here
pass4 test cases · run your code against them in the editor