Understanding the weighted cross-entropy method of u-net

I am trying to implement the weight-cross entropy mentioned in unet paper to counter the class-imbalances. I am not really able to understand how they are exactly implementing the weight-cross entropy. Quoting the paper-

where $$\ell: Ω \to {1,...,K}$$ is the true label of each pixel and $$w : Ω → \mathbb{R}$$ is a weight map that we introduced to give some pixels more importance in the training.

I have the calculated weighted function w(x) but I am not really able to understand how the modified cross-entropy is being calculated here.
Is it just by passing now the weighted function instead of the labels in regular cross-entropy or is it by multiplying the weighted function with the output of product of log of target and labels.

The standard unweighted cross-entropy loss is $$\sum_{\mathbf{x} \in \Omega} \log p_{\ell(\mathbf{x})}(\mathbf{x}).$$ The only difference in the weighted loss $$E$$ is that you have a set of multiplicative coefficients $$w(\mathbf{x})$$ that rescale the pointwise log-losses. The overall effect is that some pixels are considered more important to correctly classify.
• Thank You, now this may not be the part of the question and I could post another one if you want but how do you suggest I should incorporate w(x) in the loss. I am trying to do in this way - loss = weight_map * criterion(output,target)