Skip to content
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

Focal Loss #5313

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Focal Loss #5313

wants to merge 7 commits into from

Conversation

anishjv
Copy link

@anishjv anishjv commented Jun 21, 2024

Hello FAIR team,

I am submitting a small pull-request, which adds focal loss (as detailed in https://arxiv.org/pdf/1708.02002v2) as a possible loss function in the Fast RCNN output layer (box predictor). The new commit simply adds an attribute to the class FastRCNNOutputLayers and makes the attribute accessible from within the LazyConfig workflow. Once a LazyConfig has been instantiated using cfg = LazyConfig.load('...') the attribute can be accessed by calling cfg.model.roi_heads.box_predictor.use_focal_ce = True. The attribute's value is 'False' by default.

Using focal loss for the ROI class prediction greatly improves network validation accuracy when training on datasets with a large deal of class imbalance. Datasets with large class imbalance are extremely common for researchers working with natural data such as time lapse movies of cells, where possible classes may be "mitotic" and "non-mitotic". The typical ratio of mitotic to non-mitotic cells on a frame is 1:9, and if training a RCNN to detect cells, whole frames must be used thus excluding the possibility of balancing the dataset by training on mitotic cells only for a select number of frames. For this reason loss functions such as focal loss are highly useful.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants