I’m not completely sure, what your translate method is doing.
How did you define the target at the moment?



 Alex_Ge:

However, what is unclear is why would I use class zero.
Then I remembered reading somewhere that class 0 in segmentation is always the background or some other less useful class?


Class0 has the same importance as any other class. It is often used as the background, but you can assign whatever class you want to it.
Note that Python uses 0-indexing, which makes class0 just the first class.



 Alex_Ge:

Also, should I be applying a softmax or any other transformation to the logits, or is there no need for it?


No, as said above, nn.CrossentropyLoss expects logits and uses F.log_softmax + nn.NLLLoss internally, so you should not add a softmax layer.