MONAI icon indicating copy to clipboard operation
MONAI copied to clipboard

Weights in alpha for FocalLoss

Open szuhow opened this issue 3 months ago • 1 comments

Currently, MONAI’s FocalLoss accepts alpha as a single scalar to balance background vs. foreground. This prevents specifying different weights for each class in multi-class segmentation, which is problematic for highly imbalanced datasets. I would like FocalLoss to support alpha as a tensor or list of floats, allowing a separate weight for each class (e.g., [0.1, 0.3, 0.6] for a 3-class problem). Allowing per-class alpha directly would provide more precise control and better alignment with the original focal loss formulation.

szuhow avatar Oct 24 '25 13:10 szuhow

I would be interested in approaching this if it's open to implementation

aymuos15 avatar Nov 03 '25 22:11 aymuos15