harmonization and clarification of dice losses variants docs and associated tests #7587
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR aims to clarify and harmonise the code for the DiceLoss variants in the
monai/losses/dice.py
file. With theto_onehot_y
softmax
andsigmoid
arguments, I didn't necessarily understand the ValueError that occurred when I passed a target of size NH[WD]. I had a bit of trouble reading the documentation and understanding it. I thought that they had to be the same shape as they are displayed, unlike the number of dimensions in the input, so I added that.Besides, in the documentation is written:
Trying to reproduce this, we give an input with a number of channels$N$ and target a number of channels of $M$ , with $M \neq N$ and $M > 1$ .
This error in the Dice is an
AssertionError
and not aValueError
as expected and the explanation can be confusing and doesn't give a clear idea of the error here. The classes concerned and harmonised areDiceFocalLoss
,DiceCELoss
andGeneralizedDiceFocalLoss
with the addition of tests that behave correctly and handle this harmonisation.Also, feel free to modify or make suggestions regarding the changes made in the docstring to make them more understandable (in my opinion, but other readers and users will probably have a different view).
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.