天天看點

圖像分割類損失函數記錄以及對比1.Dice Loss 與 Dice Coefficient2.Sensitivity-Specificity Loss3.Focal Tversky Loss

1.Dice Loss 與 Dice Coefficient

dice loss源自于dice coefficient分割效果評價标準, dice coefficient具體内容如下:

def dice_coefficient(y_true, y_pre):
    eps=1e-5
    intersection = tf.reduce_sum(y_true * y_pre)
    union = tf.reduce_sum(y_true) + tf.reduce_sum(y_pre) + eps
    loss = 1. - (2 * intersection / union )
    return loss
           

dice loss:

圖像分割類損失函數記錄以及對比1.Dice Loss 與 Dice Coefficient2.Sensitivity-Specificity Loss3.Focal Tversky Loss

适用場景: 醫學影像 圖像分割 

2.Sensitivity-Specificity Loss

ss loss來源于準确度計算公式,綜合考慮靈敏度和準确度, 通過添加β系統平衡兩者之間的權重

具體損失:

def ssl(y_true,y_pred):
    elpha = 0.1
    TP = tf.reduce_sum(y_pred * y_true)
    TN = tf.reduce_sum((1-y_pred )*(1- y_true))
    FP = tf.reduce_sum(y_pred * (1-y_true))
    FN = tf.reduce_sum((1-y_pred )* y_true)
    eps = 1e-6
    sensitivity = TP/(TP+FN)
    specificity = TN/(TN+FP)
    loss = elpha * sensitivity + (1-elpha) * specificity
    return loss
           

使用場景: 需要側重TP,TN其中一個的的場合

3.Focal Tversky Loss

該損失由tversky loss改進,注重于困難樣本的訓練

首先, TI (tversky lndex):

圖像分割類損失函數記錄以及對比1.Dice Loss 與 Dice Coefficient2.Sensitivity-Specificity Loss3.Focal Tversky Loss

A表示預測值,B表示真實值,|A-B|代表FP, |B-A|代表FN,調整α與β可調整權重.

然後,FTL( focal tversky loss):

                                                                FTL =Σ (1 − TI  )^γ

γ取[1,3]

繼續閱讀