Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artemmavrin/focal-loss
TensorFlow implementation of focal loss
https://github.com/artemmavrin/focal-loss
deep-learning keras loss-functions tensorflow
Last synced: about 1 month ago
JSON representation
TensorFlow implementation of focal loss
- Host: GitHub
- URL: https://github.com/artemmavrin/focal-loss
- Owner: artemmavrin
- License: apache-2.0
- Archived: true
- Created: 2019-09-21T05:54:54.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-28T19:04:19.000Z (over 3 years ago)
- Last Synced: 2024-09-19T10:08:45.538Z (about 2 months ago)
- Topics: deep-learning, keras, loss-functions, tensorflow
- Language: Python
- Homepage: https://focal-loss.readthedocs.io
- Size: 177 KB
- Stars: 186
- Watchers: 3
- Forks: 43
- Open Issues: 6
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
==========
Focal Loss
==========.. image:: https://img.shields.io/pypi/pyversions/focal-loss
:target: https://pypi.org/project/focal-loss
:alt: Python Version.. image:: https://img.shields.io/pypi/v/focal-loss
:target: https://pypi.org/project/focal-loss
:alt: PyPI Package Version.. image:: https://img.shields.io/github/last-commit/artemmavrin/focal-loss/master
:target: https://github.com/artemmavrin/focal-loss
:alt: Last Commit.. image:: https://github.com/artemmavrin/focal-loss/workflows/Python%20package/badge.svg
:target: https://github.com/artemmavrin/focal-loss/actions?query=workflow%3A%22Python+package%22
:alt: Build Status.. image:: https://codecov.io/gh/artemmavrin/focal-loss/branch/master/graph/badge.svg
:target: https://codecov.io/gh/artemmavrin/focal-loss
:alt: Code Coverage.. image:: https://readthedocs.org/projects/focal-loss/badge/?version=latest
:target: https://focal-loss.readthedocs.io/en/latest/
:alt: Documentation Status.. image:: https://img.shields.io/github/license/artemmavrin/focal-loss
:target: https://github.com/artemmavrin/focal-loss/blob/master/LICENSE
:alt: LicenseTensorFlow implementation of focal loss [1]_: a loss function generalizing
binary and multiclass cross-entropy loss that penalizes hard-to-classify
examples.The ``focal_loss`` package provides functions and classes that can be used as
off-the-shelf replacements for ``tf.keras.losses`` functions and classes,
respectively... code-block:: python
# Typical tf.keras API usage
import tensorflow as tf
from focal_loss import BinaryFocalLossmodel = tf.keras.Model(...)
model.compile(
optimizer=...,
loss=BinaryFocalLoss(gamma=2), # Used here like a tf.keras loss
metrics=...,
)
history = model.fit(...)The ``focal_loss`` package includes the functions
* ``binary_focal_loss``
* ``sparse_categorical_focal_loss``and wrapper classes
* ``BinaryFocalLoss`` (use like ``tf.keras.losses.BinaryCrossentropy``)
* ``SparseCategoricalFocalLoss`` (use like ``tf.keras.losses.SparseCategoricalCrossentropy``)Documentation is available at
`Read the Docs `__... image:: docs/source/images/focal-loss.png
:alt: Focal loss plotInstallation
------------The ``focal_loss`` package can be installed using the
`pip `__ utility.
For the latest version, install directly from the package's
`GitHub page `__:.. code-block:: bash
pip install git+https://github.com/artemmavrin/focal-loss.git
Alternatively, install a recent release from the
`Python Package Index (PyPI) `__:.. code-block:: bash
pip install focal-loss
**Note.** To install the project for development (e.g., to make changes to
the source code), clone the project repository from GitHub and run
:code:`make dev`:.. code-block:: bash
git clone https://github.com/artemmavrin/focal-loss.git
cd focal-loss
# Optional but recommended: create and activate a new environment first
make devThis will additionally install the requirements needed to run tests, check code
coverage, and produce documentation.References
----------.. [1] T. Lin, P. Goyal, R. Girshick, K. He and P. Dollár. Focal loss for dense
object detection. IEEE Transactions on Pattern Analysis and Machine
Intelligence, 2018. (`DOI `__)
(`arXiv preprint `__)