This repo contains the code for our paper "A novel focal Tversky loss function and improved Attention U-Net for lesion segmentation" accepted at IEEE ISBI 2019.
When you've written the loss functions, did you calculate with batch data?
E.g. reading your tversky loss implementation, I think you've accidentally summed up everything aggregated over the batch instead of the data points.
For this reason your focal loss should make no difference to the simple tversky loss, because you raised the aggregated sum to the power of gamma. Instead, I believe you should raise the outputs to the power of gamma before the sum.
Of course if somehow your loss is calculated per a sample, than everything looks fine and keras made an automatic aggregation later, then everything looks fine.
Hi,
When you've written the loss functions, did you calculate with batch data? E.g. reading your tversky loss implementation, I think you've accidentally summed up everything aggregated over the batch instead of the data points.
When you do this, you sum up every prediction, but you actually want to calculate the loss for each image input. Let me suggest the following:
For this reason your focal loss should make no difference to the simple tversky loss, because you raised the aggregated sum to the power of gamma. Instead, I believe you should raise the outputs to the power of gamma before the sum.
Of course if somehow your loss is calculated per a sample, than everything looks fine and keras made an automatic aggregation later, then everything looks fine.