artemmavrin / focal-loss

TensorFlow implementation of focal loss

Home Page:https://focal-loss.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Focal Loss

Python Version

PyPI Package Version

Last Commit

Build Status

Code Coverage

Documentation Status

License

TensorFlow implementation of focal loss1: 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.

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.

Focal loss plot

Installation

The focal_loss package can be installed using the pip utility. For the latest version, install directly from the package's GitHub page:

Alternatively, install a recent release from the Python Package Index (PyPI):

Note. To install the project for development (e.g., to make changes to the source code), clone the project repository from GitHub and run make dev:

This 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)

About

TensorFlow implementation of focal loss

https://focal-loss.readthedocs.io

License:Apache License 2.0


Languages

Language:Python 98.5%Language:Makefile 1.5%