更多数学原理小文请关注公众号:未名方略
The Sørensen–Dice coefficient (see below for other names) is a statistic used to gauge the similarity of two samples. It was independently developed by the botanists Thorvald Sørensen[1] and Lee Raymond Dice,[2] who published in 1948 and 1945 respectively.
When applied to boolean data, using the definition of true positive (TP), false positive (FP), and false negative (FN), it can be written as
import keras.backend as K
smooth = 1.
def dice_coef(y_true, y_pred):
y_true_f = K.flatten(y_true)
y_pred_f = K.flatten(y_pred)
intersection = K.sum(y_true_f * y_pred_f)
return (2. * intersection + smooth) / (K.sum(y_true_f) + K.sum(y_pred_f) + smooth)
更新
根据评论讨论,探讨一下多分类的Dice计算,一般若构造损失函数,
X,Y越接近,损失函数越小。
若多分类