Dice loss not decreasing

I am using unet for segmentation purpose, I am using “1-dice_coefficient+bce” as loss function my loss function is becoming negative and not decreasing after few epochs. How to make loss function decrease?


Code:



Output:

Thanks

1 Like
  1. try only with SoftDiceLoss and see what is the result, BCE is probably correct
  2. try: score = (2*intersection+smooth)/(m1.sum+m2.sum+smooth)
  3. I am not sure if you need probs=F.sigmoid: as I understand m1 and m2 are binary.
1 Like

Thank you
m1 is not binary (because back propagation will work good if m1 is not binary, thats why it is called “SoftDiceLoss” not “HardDiceLoss” )

1 Like

@HariSumanth9 , were you able to solve this ?. What loss function did you finally use ?.

thanks

The loss should be 1- log(dice_coefficient)+bce. Now the term will always be positive.