ultrasound-nerve-segmentation icon indicating copy to clipboard operation
ultrasound-nerve-segmentation copied to clipboard

modified dice_coef_loss

Open ghost opened this issue 7 years ago • 4 comments

Hello Marko,

thank you for your U-NET implementation. I've used it to design a 3D-UNET. That was really helpful.

What do you think about a dice_coef_loss like:

def dice_coef_loss(y_true, y_pred):
    return 1.0 - dice_coef(y_true, y_pred)

This will return values between [0 , 1] and not negative ones, in comparison to other loss functions. (don't know if it makes any differences at the end)

Greetings kleinfeld

ghost avatar Apr 15 '17 12:04 ghost

Hi @kleinfeld ,

nice, I'm glad it was helpful to you! About the Dice loss - yes, you could make it like that, although it wouldn't change anything from the optimization point of view, basically it is still the same function. However, if it is clearer to you, feel free to use it like that :).

Cheers, Marko

jocicmarko avatar Apr 15 '17 14:04 jocicmarko

Hi @jocicmarko I was wondering that

intersection = K.sum(y_true_f * y_pred_f)

is this really intersection? Because lets say that true value of pixel is 0 and predicted value is also 0 in that case 0 * 0 = 0 and even if predicted value is 1 the product will be 0.

Am I missing something here?

AmmarMalik93 avatar Sep 07 '18 09:09 AmmarMalik93

@AmmarMalik93 please notice that the final loss includes "smoothing" term in both numerator and denominator, so in case if both predicted and true values are 0, the final result is 1/1=1.

jocicmarko avatar Sep 07 '18 14:09 jocicmarko

@jocicmarko thanks for the response. Yes I got it now. But there is still one confusion, for my problem I am now using the dice function same as yours but the problem is that meanwhile accuracy and intersection over union values are high the dice value being returned is very low. e.g. for a particular epoch accuracy = approx. 82% intersection over union = approx. 95% dice coefficient (using your function) = approx. 3% any ideas what I might be doing wrong here..

AmmarMalik93 avatar Sep 07 '18 14:09 AmmarMalik93