The Difference Between Dice and Dice Loss

Mohammed El Amine Mokhtari
3 min readJun 27, 2021

--

The original article on this link.

Photo by Jeswin Thomas on Unsplash

When doing image segmentation using CNNs, we often hear about the Dice coefficient, and sometimes we see the term dice loss. A lot of us get confused between these two metrics.

Physically they are the same, but when we look at their values we find that they are not the same!

The answer is very easy, but before talking about the difference between them, let’s talk about what is the dice coefficient because the dice loss is a special case of the dice coefficient.

Dice coefficient

When we do semantic segmentation for example, we want to evaluate the model either during the training which means in the validation steps or after the training which means in the testing steps. We need always to calculate a metric which is an equation between the ground truth and the predicted mask. And by looking at the values of these metrics we can say that the model is learning well or not. So the equation of the dice coefficient which can be used as a metric is two times the intersection between the ground truth and the predicted mask, divided by the sum of the ground truth and the predicted mask.

Let’s make it more clear:

The circle A is for the predicted mask and the circle B is for the ground truth.

And you can see this yellow part is the intersection between the ground truth and the predicted mask.

This will be the dice coefficient, so we can see that more the intersection will go up means that the dice value will increase as well.

The minimum value that the dice can take is 0, which is when there is no intersection between the predicted mask and the ground truth. This will give the value 0 to the numerator and of course 0 divided by anything will give 0.

The maximum value that the dice can take is 1, which means the prediction is 99% correct…

Link here

You Want to Learn Deep Learning for Medical Imaging!

Coming soon is a comprehensive medical imaging course covering 2D and 3D segmentation using Monai and PyTorch with added support. Join the waiting list to receive notifications of any course updates.

--

--

Mohammed El Amine Mokhtari
Mohammed El Amine Mokhtari

Written by Mohammed El Amine Mokhtari

I'm a computer vision research assistant, YouTuber and online content creator. Co-founder at: https://pycad.co/

No responses yet