Add label smoothing param in DiceCELoss#8000
Conversation
Fixes Project-MONAI#7957 Signed-off-by: ytl0623 <[email protected]>
KumoLiu
left a comment
There was a problem hiding this comment.
Thanks for the PR, minor comments inline.
Fixes Project-MONAI#7957 Signed-off-by: ytl0623 <[email protected]>
KumoLiu
left a comment
There was a problem hiding this comment.
Thanks for the quick update.
|
/build |
Signed-off-by: ytl0623 <[email protected]>
|
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 <[email protected]>
|
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 <[email protected]>
|
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 <[email protected]> Co-authored-by: YunLiu <[email protected]>
Fixes #7957
Description
In this modified version I made the following changes:
label_smoothing: float = 0.0parameter in__init__method, default value is 0.0.self.cross_entropyinstance, pass thelabel_smoothingparameter tonn.CrossEntropyLoss.self.label_smoothing = label_smoothingin 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 htmlcommand in thedocs/folder.