Save the date! Google I/O returns May 18-20 Register now

tfa.losses.sigmoid_focal_crossentropy

Implements the focal loss function.

Focal loss was first introduced in the RetinaNet paper (https://arxiv.org/pdf/1708.02002.pdf). Focal loss is extremely useful for classification when you have highly imbalanced classes. It down-weights well-classified examples and focuses on hard examples. The loss value is much high for a sample which is misclassified by the classifier as compared to the loss value corresponding to a well-classified example. One of the best use-cases of focal loss is its usage in object detection where the imbalance between the background class and other classes is extremely high.

y_true true targets tensor.
y_pred predictions tensor.
alpha balancing factor.
gamma modulating factor.

Weighted loss float Tensor. If reduction is NONE,this has the same shape as y_true; otherwise, it is scalar.