Thank you so much for your reply.
My output is in the shape of [batch_size, 2, h, w], and target is [batch_size, g, w], so I tried to use nn.CrossEntropyLoss, but I’m getting this error:

RuntimeError: “host_softmax” not implemented for ‘Long’

And when my output is [batch_size, 2, h, w], take for example these two cells: [0, 0, 10, 10] and [0, 1, 10, 10]. Shouldn’t the values complement each other? because the cell is in either class?