Created
October 4, 2018 10:24
-
-
Save greed2411/5bebd92e2973f80f1986991f60edd28a to your computer and use it in GitHub Desktop.
dice coefficient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dice_loss(input, target): | |
smooth = 1. | |
iflat = input.view(-1) | |
tflat = target.view(-1) | |
intersection = (iflat * tflat).sum() | |
return 1 - ((2. * intersection + smooth) / | |
(iflat.sum() + tflat.sum() + smooth)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment