Created
March 10, 2021 23:31
-
-
Save sohiniroych/68ce46adfae0400acc5fe833d96f6464 to your computer and use it in GitHub Desktop.
loss functions for semantic segmentation
This file contains hidden or 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_coef(y_true, y_pred, smooth=1): | |
| intersection = keras.sum(y_true * y_pred, axis=[1,2,3]) | |
| union = keras.sum(y_true, axis=[1,2,3]) + keras.sum(y_pred, axis=[1,2,3]) | |
| return keras.mean( (2. * intersection + smooth) / (union + smooth), axis=0) | |
| def dice_coef_loss(y_true, y_pred): | |
| return -dice_coef(y_true, y_pred) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment