Loss Functions For Segmentation

#artificialintelligence 

In this post, I will implement some of the most common loss functions for image segmentation in Keras/TensorFlow. I will only consider the case of two classes (i.e. Due to numerical stability, it is always better to use BinaryCrossentropy with from_logits True. You can see in the original code that TensorFlow sometimes tries to compute cross entropy from probabilities (when from_logits False). Due to numerical instabilities clip_by_value becomes then necessary.