neural network probability output and loss function (example: dice loss)
I think there is a bit of confusion here. The dice coefficient is defined for binary classification. Softmax is used for multiclass classification.

Softmax and sigmoid are both interpreted as probabilities, the difference is in what these probabilities are. For binary classification they are basically equivalent, but for multiclass classification there is a difference.

When you apply sigmoid, you make sure that all output neurons are between 0 and 1.

When you apply softmax, you make sure that all output neurons are between 0 and 1 AND that they sum up to 1.

This means, when the output is sigmoid, the input data can be in several classes at the same time. For softmax, you force the network to pick one of the classes. 

The code you posted here is correct for binary classification, but for multiclass, there is some intricacy when it comes to combining the classes.

Since in your example the target consists of two pixels, each labeled either 0 or 1, you are dealing with binary classification and should use pixel-wise sigmoid in the first place, i.e. the probabilities from your model should be e.g. [0.7, 0.8] or something like that.

Pixel-wise softmax should only be used if each pixel could be in only one of many classes and softmax over all pixels does not make much sense, as this would force the model to pick one out of many pixels to label as 1.