-
Notifications
You must be signed in to change notification settings - Fork 34
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
[Feature Request]: Adding Categorical Focal Loss #259
Labels
Comments
Thanks for raising this issue. This would be a useful feature. Would you be able to contribute with a PR. Please also look at reference implementation in tesorflow-addons package. |
@sampathweb Yes I can contribute with a PR, I'll start working on it. Edit: This is in progress. |
copybara-service bot
referenced
this issue
in keras-team/keras
Mar 23, 2023
Imported from GitHub PR #17651 Implements the `CategoricalFocalCrossentropy()` loss based on the paper [Focal Loss for Dense Object Detection](https://arxiv.org/pdf/1708.02002.pdf) (Lin et al., 2018). Feature request was made in #17583. Copybara import of the project: -- 5696b5a by Kaan Bıçakcı <[email protected]>: Add pure logic of CFCE -- 40e547f by Kaan Bıçakcı <[email protected]>: Add support for ragged tensors -- d3dd32f by Kaan Bıçakcı <[email protected]>: Make sure output sum equals 1 -- 16adf85 by Kaan Bıçakcı <[email protected]>: Raise shape mismatch / update tests -- bc38e33 by Kaan Bıçakcı <[email protected]>: Add categorical_focal_loss tests -- 363baaf by Kaan Bıçakcı <[email protected]>: Add documentation / minor fix. -- c267fa0 by Kaan Bıçakcı <[email protected]>: Reformatting after focal loss implementation -- 3c33117 by Kaan Bıçakcı <[email protected]>: Fix linting. -- 3538622 by Kaan Bıçakcı <[email protected]>: Fix docstring style. -- 6b4fa6b by Kaan Bıçakcı <[email protected]>: Update the docstrings. -- 49c03a2 by Kaan Bıçakcı <[email protected]>: Fix linting issues Merging this change closes #17651 FUTURE_COPYBARA_INTEGRATE_REVIEW=#17651 from Frightera:frightera_categorical_focal_loss_v2 49c03a2 PiperOrigin-RevId: 518880861
copybara-service bot
referenced
this issue
in keras-team/keras
Mar 27, 2023
Imported from GitHub PR #17651 Implements the `CategoricalFocalCrossentropy()` loss based on the paper [Focal Loss for Dense Object Detection](https://arxiv.org/pdf/1708.02002.pdf) (Lin et al., 2018). Feature request was made in #17583. Copybara import of the project: -- 5696b5a by Kaan Bıçakcı <[email protected]>: Add pure logic of CFCE -- 40e547f by Kaan Bıçakcı <[email protected]>: Add support for ragged tensors -- d3dd32f by Kaan Bıçakcı <[email protected]>: Make sure output sum equals 1 -- 16adf85 by Kaan Bıçakcı <[email protected]>: Raise shape mismatch / update tests -- bc38e33 by Kaan Bıçakcı <[email protected]>: Add categorical_focal_loss tests -- 363baaf by Kaan Bıçakcı <[email protected]>: Add documentation / minor fix. -- c267fa0 by Kaan Bıçakcı <[email protected]>: Reformatting after focal loss implementation -- 3c33117 by Kaan Bıçakcı <[email protected]>: Fix linting. -- 3538622 by Kaan Bıçakcı <[email protected]>: Fix docstring style. -- 6b4fa6b by Kaan Bıçakcı <[email protected]>: Update the docstrings. -- 49c03a2 by Kaan Bıçakcı <[email protected]>: Fix linting issues -- f560336 by Kaan Bıçakcı <[email protected]>: Address comments from code-review. Merging this change closes #17651 FUTURE_COPYBARA_INTEGRATE_REVIEW=#17651 from Frightera:frightera_categorical_focal_loss_v2 f560336 PiperOrigin-RevId: 518880861
copybara-service bot
referenced
this issue
in keras-team/keras
Mar 27, 2023
Imported from GitHub PR #17651 Implements the `CategoricalFocalCrossentropy()` loss based on the paper [Focal Loss for Dense Object Detection](https://arxiv.org/pdf/1708.02002.pdf) (Lin et al., 2018). Feature request was made in #17583. Copybara import of the project: -- 5696b5a by Kaan Bıçakcı <[email protected]>: Add pure logic of CFCE -- 40e547f by Kaan Bıçakcı <[email protected]>: Add support for ragged tensors -- d3dd32f by Kaan Bıçakcı <[email protected]>: Make sure output sum equals 1 -- 16adf85 by Kaan Bıçakcı <[email protected]>: Raise shape mismatch / update tests -- bc38e33 by Kaan Bıçakcı <[email protected]>: Add categorical_focal_loss tests -- 363baaf by Kaan Bıçakcı <[email protected]>: Add documentation / minor fix. -- c267fa0 by Kaan Bıçakcı <[email protected]>: Reformatting after focal loss implementation -- 3c33117 by Kaan Bıçakcı <[email protected]>: Fix linting. -- 3538622 by Kaan Bıçakcı <[email protected]>: Fix docstring style. -- 6b4fa6b by Kaan Bıçakcı <[email protected]>: Update the docstrings. -- 49c03a2 by Kaan Bıçakcı <[email protected]>: Fix linting issues -- f560336 by Kaan Bıçakcı <[email protected]>: Address comments from code-review. Merging this change closes #17651 FUTURE_COPYBARA_INTEGRATE_REVIEW=#17651 from Frightera:frightera_categorical_focal_loss_v2 f560336 PiperOrigin-RevId: 519824695
copybara-service bot
referenced
this issue
in keras-team/keras
Mar 28, 2023
Imported from GitHub PR #17651 Implements the `CategoricalFocalCrossentropy()` loss based on the paper [Focal Loss for Dense Object Detection](https://arxiv.org/pdf/1708.02002.pdf) (Lin et al., 2018). Feature request was made in #17583. Copybara import of the project: -- 5696b5a by Kaan Bıçakcı <[email protected]>: Add pure logic of CFCE -- 40e547f by Kaan Bıçakcı <[email protected]>: Add support for ragged tensors -- d3dd32f by Kaan Bıçakcı <[email protected]>: Make sure output sum equals 1 -- 16adf85 by Kaan Bıçakcı <[email protected]>: Raise shape mismatch / update tests -- bc38e33 by Kaan Bıçakcı <[email protected]>: Add categorical_focal_loss tests -- 363baaf by Kaan Bıçakcı <[email protected]>: Add documentation / minor fix. -- c267fa0 by Kaan Bıçakcı <[email protected]>: Reformatting after focal loss implementation -- 3c33117 by Kaan Bıçakcı <[email protected]>: Fix linting. -- 3538622 by Kaan Bıçakcı <[email protected]>: Fix docstring style. -- 6b4fa6b by Kaan Bıçakcı <[email protected]>: Update the docstrings. -- 49c03a2 by Kaan Bıçakcı <[email protected]>: Fix linting issues -- f560336 by Kaan Bıçakcı <[email protected]>: Address comments from code-review. Merging this change closes #17651 FUTURE_COPYBARA_INTEGRATE_REVIEW=#17651 from Frightera:frightera_categorical_focal_loss_v2 f560336 PiperOrigin-RevId: 519824695
Closing as PR is merged now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
System information.
TensorFlow version (you are using): 2.11
Are you willing to contribute it (Yes/No) : Yes
Describe the feature and the current behavior/state.
Currently, Keras provides built-in implementation of Binary Focal Crossentropy. However, it does not provide a built-in implementation of the Categorical Focal Loss.
Related SO questions:
https://stackoverflow.com/questions/56293964/categorical-focal-loss-on-keras
https://stackoverflow.com/questions/65875860/how-to-use-categorial-focal-loss-for-one-hot-encoding-with-keras
https://stackoverflow.com/questions/57807175/use-of-1-a-weight-in-categorical-focal-loss
https://stackoverflow.com/questions/70459884/can-sigmoidfocalcrossentropy-in-tensorflow-tf-addons-be-used-in-multiclass-cla
Some repositories:
https://github.com/umbertogriffo/focal-loss-keras
https://github.com/artemmavrin/focal-loss
Will this change the current api? How?
Yes, this will change the current API by adding a new built-in loss function to Keras.
Contributing
The text was updated successfully, but these errors were encountered: