Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5919 fix generalized dice issue #5929

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion monai/metrics/generalized_dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ def compute_generalized_dice(
y_pred_o = y_pred_o.sum(dim=-1)
denom_zeros = denom == 0
generalized_dice_score[denom_zeros] = torch.where(
(y_pred_o == 0)[denom_zeros], torch.tensor(1.0), torch.tensor(0.0)
(y_pred_o == 0)[denom_zeros],
yiheng-wang-nv marked this conversation as resolved.
Show resolved Hide resolved
torch.tensor(1.0, device=generalized_dice_score.device),
torch.tensor(0.0, device=generalized_dice_score.device),
)

return generalized_dice_score