Focal LossΒΆ

Focal Loss for Dense Object Detection
address this class imbalance by reshaping the standard cross entropy loss such that it down-weights the loss assigned to well-classified examples ../../_images/focal_loss.png

For notational convenience:

\[\begin{split}p_t= \begin{cases} \hat{y} , & \text{if } y=1\\ 1-\hat{y} , & \text{otherwise} \end{cases}\end{split}\]

focal loss

\[FL(y) = -(1-p_t)^\gamma log(p_t)\]

\(\alpha\)-balanced variant

\[\begin{split}FL(y) &= -\alpha_t(1-p_t)^\gamma log(p_t)\\ &=-\alpha_t \begin{cases} (1-\hat{y})^\gamma log(\hat{y}) , & \text{if } y=1 \\ \hat{y}^\gamma log(1-\hat{y}) , & \text{otherwise} \end{cases} \\ &= -\alpha_t(y(1-\hat{y})^\gamma log(\hat{y}) +(1-y)\hat{y}^\gamma log(1-\hat{y}))\end{split}\]