Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add label smoothing param in DiceCELoss (Project-MONAI#8000)
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>
- Loading branch information