Project-MONAI / Project-MONAI/MONAI

In MONAI's focal loss implementation, why does the alpha parameter become invalid when softmax is used and include_background=False?

Open
#8,117 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.7k
Forks
1.6k
Avg merge
5d 1h
Merged PRs (30d)
20

Description

Discussed in https://github.com/Project-MONAI/MONAI/discussions/8116

Originally posted by dancingreindeer September 26, 2024

if self.use_softmax: 
   if not self.include_background and self.alpha is not None: 
            self.alpha = None 
            warnings.warn("include_background=False, alpha ignored when using softmax.") 
        loss = softmax_focal_loss(input, target, self.gamma, self.alpha)

This is the code piece. Not sure why when we don't include background and when using softmax, alpha became invalid? Does this assume there are no label imbalance? How to address this when there is significantly more negative samples than positive samples in the experiment then?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the focal loss implementation's softmax branch shown in the issue and read the linked discussion #8116. Determine why alpha is cleared when include_background=False, whether this reflects a limitation or intended behavior, and document how class imbalance should be handled in this configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.