-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add label smoothing param in DiceCELoss #8000
Conversation
Fixes Project-MONAI#7957 Signed-off-by: ytl0623 <david89062388@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, minor comments inline.
Fixes Project-MONAI#7957 Signed-off-by: ytl0623 <david89062388@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick update.
/build |
Signed-off-by: ytl0623 <david89062388@gmail.com>
Hi @KumoLiu, Please review the changes to ensure the maximum length limit. Thank you! |
/build |
Hi @ytl0623,
And the reason is that Something like: MONAI/monai/engines/trainer.py Line 186 in 660891f
Thanks! |
Signed-off-by: ytl0623 <david89062388@gmail.com>
Hi @KumoLiu, I think this is okay now. Could you please help me make some corrections? Thanks for your help. |
Could you please run |
Signed-off-by: ytl0623 <david89062388@gmail.com>
Hi @KumoLiu, Done! Thanks :) |
/build |
/build |
Fixes Project-MONAI#7957 ### Description In this modified version I made the following changes: 1. Added `label_smoothing: float = 0.0` parameter in `__init__` method, default value is 0.0. 2. When creating the `self.cross_entropy` instance, pass the `label_smoothing` parameter to `nn.CrossEntropyLoss`. 3. Added `self.label_smoothing = label_smoothing` in the `__init__` method to save this parameter for access when needed. For example: ``` from monai.losses import DiceCELoss # Before criterion = DiceCELoss() criterion.cross_entropy.label_smoothing = 0.1 # Now criterion = DiceCELoss(label_smoothing=0.1) ``` ### 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). - [ ] 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: ytl0623 <david89062388@gmail.com> Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #7957
Description
In this modified version I made the following changes:
label_smoothing: float = 0.0
parameter in__init__
method, default value is 0.0.self.cross_entropy
instance, pass thelabel_smoothing
parameter tonn.CrossEntropyLoss
.self.label_smoothing = label_smoothing
in the__init__
method to save this parameter for access when needed.For example:
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.