Could I use the metric Dice as the loss_func for unet_learner?

Hi, I have added Dice to my metrics array of the unet learner.

However, I was wondering if it is possible to use it as the loss function of the learner?

If you want to use dice as part of a loss you need to use 1-dice instead, as it has to decrease when your model gets better. However there is an important edge case : when you have empty masks in your dataset, the dice loss creates a discontinuity around that case, which is very bad for training. So be careful with that.

What do you mean by empty mask?

A segmentation mask where there is only background.