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

NACLLoss memory management #8020

Merged
merged 58 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
8fbec82
Initial commit -- Adding calibration loss specific to segmentation
Bala93 Jun 2, 2024
23b897b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 2, 2024
b2ec62b
Update __init__.py
Bala93 Jun 2, 2024
93ee114
Update segcalib.py
Bala93 Jun 2, 2024
42e732b
Update segcalib.py
Bala93 Jun 2, 2024
187053d
Update segcalib.py
Bala93 Jun 2, 2024
1d27ec5
Update segcalib.py
Bala93 Jun 2, 2024
d499134
Update segcalib.py
Bala93 Jun 3, 2024
1e3f755
Update segcalib.py
Bala93 Jun 3, 2024
9dedfba
Update segcalib.py
Bala93 Jun 4, 2024
59959ce
Update monai/losses/segcalib.py
Bala93 Jun 14, 2024
cf1d044
Update monai/losses/segcalib.py
Bala93 Jun 14, 2024
0926851
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 14, 2024
5317706
Update segcalib.py
Bala93 Jun 15, 2024
3155433
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 15, 2024
7c121a0
Add specific to gaussian for both 2d and 3d
Bala93 Aug 3, 2024
24efd85
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 3, 2024
0067953
Merge branch 'Project-MONAI:dev' into model-calibration
Bala93 Aug 3, 2024
dccde47
Add mean loss and resolve formatting
Bala93 Aug 3, 2024
44e8065
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 3, 2024
57686d7
Merge branch 'dev' into model-calibration
Bala93 Aug 3, 2024
5cd9a33
Update segcalib.py
Bala93 Aug 3, 2024
b547c4e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 3, 2024
42a0215
Update segcalib.py
Bala93 Aug 3, 2024
7e36ca1
Update segcalib.py
Bala93 Aug 3, 2024
6dbd53d
Update segcalib.py
Bala93 Aug 3, 2024
354056c
Update segcalib.py
Bala93 Aug 4, 2024
7eb911f
Update segcalib.py
Bala93 Aug 4, 2024
0b1209b
Update segcalib.py
Bala93 Aug 4, 2024
035c92e
Update segcalib.py
Bala93 Aug 4, 2024
c1de5f1
Rename segcalib.py to nacl_loss.py
Bala93 Aug 5, 2024
91dd1b9
Update __init__.py
Bala93 Aug 5, 2024
9702c02
Update test_nacl_loss.py
Bala93 Aug 5, 2024
4462379
Update nacl_loss.py
Bala93 Aug 5, 2024
c4f8283
Update test_nacl_loss.py
Bala93 Aug 5, 2024
bc6b995
Update test_nacl_loss.py
Bala93 Aug 5, 2024
51e15fe
Added missing parameters in doc
Bala93 Aug 5, 2024
3a00aec
Formatting check with monai
Bala93 Aug 5, 2024
818b42b
Update test_nacl_loss.py
Bala93 Aug 5, 2024
6647708
Added mypy fixes
Bala93 Aug 5, 2024
7e579dd
DCO Remediation Commit for bala93 <balamuralim.1993@gmail.com>
Bala93 Aug 5, 2024
4f8abf1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 5, 2024
b72e478
Update docs/source/losses.rst
Bala93 Aug 6, 2024
747681d
* Include test cases covering more cases
Bala93 Aug 7, 2024
3b15554
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 7, 2024
877139c
Update monai/losses/nacl_loss.py
Bala93 Aug 7, 2024
4679456
Update monai/losses/nacl_loss.py
Bala93 Aug 7, 2024
7c5217e
* Add docstring with better explanations
Bala93 Aug 7, 2024
d33f435
* Maintain the dimension consistency.
Bala93 Aug 7, 2024
7deb2cc
Update nacl_loss.py
Bala93 Aug 7, 2024
91ce50b
Update nacl_loss.py
Bala93 Aug 7, 2024
7f87e0c
Merge branch 'model-calibration' of https://github.com/Bala93/MONAI i…
Bala93 Aug 7, 2024
0e880a8
Modify docstring
Bala93 Aug 7, 2024
db9daeb
Merge branch 'dev' into model-calibration
KumoLiu Aug 8, 2024
f579763
Update nacl_loss.py
Bala93 Aug 15, 2024
c579768
Merge branch 'dev' into model-calibration
Bala93 Aug 15, 2024
80ac3d8
DCO Remediation Commit for Balamurali <balamuralim.1993@gmail.com>
Bala93 Aug 15, 2024
2469e14
Merge branch 'dev' into model-calibration
KumoLiu Aug 15, 2024
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: 2 additions & 2 deletions monai/losses/nacl_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ def get_constr_target(self, mask: torch.Tensor) -> torch.Tensor:
rmask: torch.Tensor

if self.dim == 2:
oh_labels = F.one_hot(mask.to(torch.int64), num_classes=self.nc).contiguous().permute(0, 3, 1, 2).float()
oh_labels = F.one_hot(mask.to(torch.int64), num_classes=self.nc).permute(0, 3, 1, 2).contiguous().float()
rmask = self.svls_layer(oh_labels)

if self.dim == 3:
oh_labels = F.one_hot(mask.to(torch.int64), num_classes=self.nc).contiguous().permute(0, 4, 1, 2, 3).float()
oh_labels = F.one_hot(mask.to(torch.int64), num_classes=self.nc).permute(0, 4, 1, 2, 3).contiguous().float()
rmask = self.svls_layer(oh_labels)

return rmask
Expand Down
1 change: 1 addition & 0 deletions tests/test_nacl_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

TEST_CASES = [
[{"classes": 3, "dim": 2}, {"inputs": inputs, "targets": targets}, 1.1442],
[{"classes": 3, "dim": 2}, {"inputs": inputs.repeat(4, 1, 1, 1), "targets": targets.repeat(4, 1, 1)}, 1.1442],
[{"classes": 3, "dim": 2, "kernel_ops": "gaussian"}, {"inputs": inputs, "targets": targets}, 1.1433],
[{"classes": 3, "dim": 2, "kernel_ops": "gaussian", "sigma": 0.5}, {"inputs": inputs, "targets": targets}, 1.1469],
[{"classes": 3, "dim": 2, "distance_type": "l2"}, {"inputs": inputs, "targets": targets}, 1.1269],
Expand Down
Loading