Skip to content

Conversation

@ytl0623
Copy link
Contributor

@ytl0623 ytl0623 commented Jan 15, 2026

Fixes #8689 .

Description

Update the docstrings to match the actual code defaults.

Types of changes

  • 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]>
Signed-off-by: ytl0623 <[email protected]>
Signed-off-by: ytl0623 <[email protected]>
… the weight for positive samples of class c. Negative samples should have a default weight of 1.0

Signed-off-by: ytl0623 <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The focal loss module has been extended to support per-class alpha weighting. The FocalLoss class and softmax/sigmoid focal loss functions now accept alpha as either a scalar or a sequence of class weights, with updated signatures and validation logic. Scalar alpha follows the standard background/other-class weighting pattern, while sequence alpha applies per-class weights with appropriate broadcasting. In unified focal loss, docstrings were corrected to reflect actual gamma defaults: 2.0 for AsymmetricFocalLoss and 0.5 for AsymmetricUnifiedFocalLoss. Tests now verify alpha sequence broadcasting across multiple device and configuration combinations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 57fdd59 and 9546f8e.

📒 Files selected for processing (3)
  • monai/losses/focal_loss.py
  • monai/losses/unified_focal_loss.py
  • tests/losses/test_focal_loss.py

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ytl0623 ytl0623 closed this Jan 15, 2026
@ytl0623 ytl0623 deleted the fix-issue-8689 branch January 15, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect gamma default values in unified_focal_loss.py docstrings

1 participant