-
Notifications
You must be signed in to change notification settings - Fork 19.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR #17651: Add CategoricalFocalCrossentropy to Losses API
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
- Loading branch information
1 parent
42047cc
commit 5946ee4
Showing
12 changed files
with
699 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
keras/api/golden/v1/tensorflow.keras.losses.-categorical-focal-crossentropy.pbtxt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
path: "tensorflow.keras.losses.CategoricalFocalCrossentropy" | ||
tf_class { | ||
is_instance: "<class \'keras.losses.CategoricalFocalCrossentropy\'>" | ||
is_instance: "<class \'keras.losses.LossFunctionWrapper\'>" | ||
is_instance: "<class \'keras.losses.Loss\'>" | ||
is_instance: "<type \'object\'>" | ||
member_method { | ||
name: "__init__" | ||
argspec: "args=[\'self\', \'alpha\', \'gamma\', \'from_logits\', \'label_smoothing\', \'axis\', \'reduction\', \'name\'], varargs=None, keywords=None, defaults=[\'0.25\', \'2.0\', \'False\', \'0.0\', \'-1\', \'auto\', \'categorical_focal_crossentropy\'], " | ||
} | ||
member_method { | ||
name: "call" | ||
argspec: "args=[\'self\', \'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" | ||
} | ||
member_method { | ||
name: "from_config" | ||
argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" | ||
} | ||
member_method { | ||
name: "get_config" | ||
argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
keras/api/golden/v2/tensorflow.keras.losses.-categorical-focal-crossentropy.pbtxt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
path: "tensorflow.keras.losses.CategoricalFocalCrossentropy" | ||
tf_class { | ||
is_instance: "<class \'keras.losses.CategoricalFocalCrossentropy\'>" | ||
is_instance: "<class \'keras.losses.LossFunctionWrapper\'>" | ||
is_instance: "<class \'keras.losses.Loss\'>" | ||
is_instance: "<type \'object\'>" | ||
member_method { | ||
name: "__init__" | ||
argspec: "args=[\'self\', \'alpha\', \'gamma\', \'from_logits\', \'label_smoothing\', \'axis\', \'reduction\', \'name\'], varargs=None, keywords=None, defaults=[\'0.25\', \'2.0\', \'False\', \'0.0\', \'-1\', \'auto\', \'categorical_focal_crossentropy\'], " | ||
} | ||
member_method { | ||
name: "call" | ||
argspec: "args=[\'self\', \'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" | ||
} | ||
member_method { | ||
name: "from_config" | ||
argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" | ||
} | ||
member_method { | ||
name: "get_config" | ||
argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.