I assume you are using nn.CrossEntropyLoss for your segmentation use case.
If that’s the case, then you would have to pass the target mask in the shape [batch_size, height, width] as a LongTensor containing the class indices in the range [0, nb_classes-1].
Based on the shape of your mask, it seems it might be an RGB image?
If so, you would need to map the colors to class indices first.