I am using a CNN (U-Net) in Keras to segment an 8 bit image to get a binary mask. Despite reaching an accuracy of 0.9999 I still get a few values that are between 0 and 255 but would like to completely remove these values to have only 0 or 255. I have so far been using the binary cross entropy loss function, combined with a sigmoid activation function the last convolutional layer. Can someone tell me if there are other loss functions that could possibly solve this problem.