Skip to content

Add binary focal cross entropy loss function - #498

Closed
ZJUGuoShuai wants to merge 1 commit into
ml-explore:mainfrom
ZJUGuoShuai:add-bfce-loss
Closed

ZJUGuoShuai wants to merge 1 commit into
ml-explore:mainfrom
ZJUGuoShuai:add-bfce-loss

Conversation

@ZJUGuoShuai

@ZJUGuoShuai ZJUGuoShuai commented Jan 19, 2024 •

Copy link
Copy Markdown
Contributor

Proposed changes

This PR adds the Binary Focal Cross-entropy Loss, which is introduced by Lin et al., 2018 and often used in object detection tasks.

The interface is nearly the same with TensorFlow's tf.keras.losses.BinaryFocalCrossentropy and the test ground-truth values are calculated by it to ensure correctness.

This implementation supports both logits and probabilities as input (like the normal binary_cross_entropy). It also supports class balancing in Lin et al., 2018, like TF's BinaryFocalCrossentropy.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

@awni

awni commented Jan 23, 2024

Copy link
Copy Markdown
Member

Thanks for the contribution! We decided against adding this to MLX core in #336 and #324 as it's a bit niche. We may revisit in the future.

For future reference, it's a good idea to open an issue about possible new features before or in tandem to starting a PR so we can let you know if there is ongoing work / plans already / not for core.

@awni awni closed this Jan 23, 2024
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.

3 participants