Problem with Dice and its Derivative formula?
navidsamavati opened this issue · 4 comments
Hello Fausto,
I have been trying to understand your definition of Dice in the paper, and its derivative implemented in pyLayer.py
The issues are:
-
Why do you have squared terms for each voxel in the denominator of Dice formula? Shouldn't they be just the voxels and not the squared of voxel values, which are (0 or 1)?
-
Given your derivative calculation in the paper (which seems alright to me), you have a different (perhaps mistakenly) implementation in pylayer.py! You have the following:
bottom[btm].diff[i, 0, :] += 2.0 * (
(self.gt[i, :] * self.union[i]) / ((self.union[i]) ** 2) - 2.0prob[i,1,:](self.intersection[i]) / (
(self.union[i]) ** 2))
But, it really should be:
bottom[btm].diff[i, 0, :] += 2.0 * (
(self.gt[i, :] * self.union[i]) - 2.0prob[i,1,:](self.intersection[i]) / (
(self.union[i]) ** 2))
in which "((self.union[i]) ** 2)" has been eliminated from the denominator of the first term.
Can you please look into this, and clarify?
Having raised these ambiguities, I have to say that I really appreciate your great work, and have been studying it for a while now.
Thanks!
Navid
Awesome! Thanks for clarifying this. I worked out the Dice formula with squared terms. You are indeed right. Great work!
I still think that the derivative implementation in pyLayer.py is not exactly the same as the derivative formula in the paper. I did the derivative myself, and got your formula in the paper. So, I guess there might be a typo in the brackets provided in the pyLayer.py in lines 61 - 66. I actually provided the modifications, that I think are necessary, in my comment above.
Do you agree?
Thanks again for your response!
Best,
Navid
Indeed your implementation was correct :) 👍 👍
Sorry for the confusion!
Best,
Navid