Solved by ptrblck in post #3 
              
              
                nn.BCEWithLogitsLoss expects your model output to be logits, so you shouldn’t use a threshold on them. 
On the other side, your custom DiceLoss might expect class predictions, but that depends on your implementation of it.