Skip to content

Conversation

@KumoLiu
Copy link
Contributor

@KumoLiu KumoLiu commented Nov 4, 2022

Signed-off-by: KumoLiu yunl@nvidia.com

Fixes #5466.

Description

In GeneralizedDiceLoss, now it do channel reduction before reduction, remove channel reduction in this PR.

MONAI/monai/losses/dice.py

Lines 360 to 363 in c38d503

final_reduce_dim = 0 if self.batch else 1
numer = 2.0 * (intersection * w).sum(final_reduce_dim, keepdim=True) + self.smooth_nr
denom = (denominator * w).sum(final_reduce_dim, keepdim=True) + self.smooth_dr
f: torch.Tensor = 1.0 - (numer / denom)

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Signed-off-by: KumoLiu <yunl@nvidia.com>
@KumoLiu KumoLiu requested review from Nic-Ma, ericspod, rijobro and wyli and removed request for wyli November 4, 2022 10:31
@wyli
Copy link
Contributor

wyli commented Nov 4, 2022

/build

@wyli wyli enabled auto-merge (squash) November 4, 2022 13:39
@wyli wyli merged commit e03ecd4 into Project-MONAI:dev Nov 4, 2022
@KumoLiu KumoLiu deleted the fix-generalized-dice-loss branch November 4, 2022 14:51
wyli pushed a commit that referenced this pull request Nov 6, 2022
Signed-off-by: KumoLiu <yunl@nvidia.com>

Fixes #5466.

### Description
In `GeneralizedDiceLoss`, now it do channel reduction before reduction,
remove channel reduction in this PR.

https://github.com/Project-MONAI/MONAI/blob/c38d503a587f1779914bd071a1b2d66a6d9080c2/monai/losses/dice.py#L360-L363

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: KumoLiu <yunl@nvidia.com>
wyli added a commit to wyli/MONAI that referenced this pull request Jul 25, 2023
This reverts commit e03ecd4.

Signed-off-by: Wenqi Li <wenqil@nvidia.com>
wyli added a commit to wyli/MONAI that referenced this pull request Jul 26, 2023
This reverts commit e03ecd4.

Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generalized Dice Loss - Reduction="none" + batch=True

2 participants