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.

Dice系数公式与伪码

When applied to boolean data, using the definition of true positive (TP), false positive (FP), and false negative (FN), it can be written as

Dice系数公式与伪码

Dice系数公式与伪码

 

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)

 

相关文章:

  • 2021-10-14
  • 2021-08-05
  • 2022-12-23
猜你喜欢
  • 2021-11-21
  • 2022-01-28
  • 2021-10-07
  • 2022-01-28
  • 2021-11-02
相关资源
相似解决方案