So I added this line in my validation code (after the loss function):
pred_val_mask = (pred_val_mask>0.5).float()

But as you can see the discrepancies in dice score still exist when different validation batch sizes are used.:

W&amp;B Chart 05_09_2019, 13_40_27.png809×259 14.7 KB

@Latope2-150 Yes val_mask is a tensor of 1s and 0s representing the segmentation mask. Without the binary masking the dice_loss would have been measuring the ‘soft’ dice score instead of a binary dice score.