/FocalLoss_Keras

Focal Loss implementation by Keras with TensorFlow backend

Primary LanguagePythonMIT LicenseMIT

Focal Loss

This is the keras implementation of focal loss with the backend of tensorflow. The Focal Loss is proposed for dealing with foreground-backgrou class imbalance. 论文中的结果图Fig1

Usage

Compile your model with focal loss as sample:

model.compile(optimizer = Adam(lr = 1e-4), loss = [focal_loss(gamma=2,alpha=0.6)], metrics = ['accuracy'])

Experiments

We implement U-Net: Convolutional Networks for Biomedical Image Segmentation with Focal Loss and get the results of different parameters as follows: 不同的图像fig2 fig1

曲线图fig3

fig2

From fig2, we found the improvement of focal is not ideal. And different parameters have a greater impact.

Breaks

We found that the Focal Loss is not stable and I think the main reason is parameters initialization. I wil try to fix it.

Others

The implemented code is based @zhixuhao' code