Skip to content

Explicitly set reduction for Focal loss #1165

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

Merged
merged 1 commit into from
Jun 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions segmentation_models_pytorch/losses/focal.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

self.mode = mode
self.ignore_index = ignore_index
self.reduction = reduction

Check warning on line 48 in segmentation_models_pytorch/losses/focal.py

View check run for this annotation

Codecov / codecov/patch

segmentation_models_pytorch/losses/focal.py#L48

Added line #L48 was not covered by tests
self.focal_loss_fn = partial(
focal_loss_with_logits,
alpha=alpha,
Expand Down
Loading