Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
285 B
1
Indexable
Never
def dice_coef(y_true, y_pred):
    y_true_f = keras.backend.flatten(y_true)
    y_pred_f = keras.backend.flatten(y_pred)
    
    intersection = keras.backend.sum(y_true_f * y_pred_f)
    return (2.0 * intersection + 1) / (keras.backend.sum(y_true_f) + keras.backend.sum(y_pred_f) + 1)