Description
The docstrings in monai/losses/unified_focal_loss.py have incorrect default values for the gamma parameter. The code defaults are correct (matching the original author's implementation referenced in #4413), but the docstrings incorrectly state 0.75 for all classes.
Comparison with Original Implementation
| Loss Function |
Original Default γ |
MONAI Code |
MONAI Docstring |
AsymmetricFocalLoss |
2.0 |
gamma: float = 2 ✓ |
"Defaults to 0.75" ✗ |
AsymmetricFocalTverskyLoss |
0.75 |
gamma: float = 0.75 ✓ |
"Defaults to 0.75" ✓ |
AsymmetricUnifiedFocalLoss |
0.5 |
gamma: float = 0.5 ✓ |
"Defaults to 0.75" ✗ |
Specific Issues
-
AsymmetricFocalLoss (line 103, 111):
- Code:
gamma: float = 2
- Docstring says:
Defaults to 0.75
-
AsymmetricUnifiedFocalLoss (line 162, 171):
- Code:
gamma: float = 0.5
- Docstring says:
Defaults to 0.75
-
AsymmetricUnifiedFocalLoss also documents an epsilon parameter (line 172) that doesn't exist in the __init__ signature.
References
Suggested Fix
Update the docstrings to match the actual code defaults (which are correct per the original implementation).
I am happy to create a PR if this fix is acceptable.
Description
The docstrings in
monai/losses/unified_focal_loss.pyhave incorrect default values for thegammaparameter. The code defaults are correct (matching the original author's implementation referenced in #4413), but the docstrings incorrectly state0.75for all classes.Comparison with Original Implementation
AsymmetricFocalLossgamma: float = 2✓AsymmetricFocalTverskyLossgamma: float = 0.75✓AsymmetricUnifiedFocalLossgamma: float = 0.5✓Specific Issues
AsymmetricFocalLoss (line 103, 111):
gamma: float = 2Defaults to 0.75AsymmetricUnifiedFocalLoss (line 162, 171):
gamma: float = 0.5Defaults to 0.75AsymmetricUnifiedFocalLoss also documents an
epsilonparameter (line 172) that doesn't exist in the__init__signature.References
Suggested Fix
Update the docstrings to match the actual code defaults (which are correct per the original implementation).
I am happy to create a PR if this fix is acceptable.