Solved by smth in post #2 
              
              
                you can just use CrossEntropyLoss in this case, and it will treat C as the slicing dimension for softmax, i.e. each [N, H, W] slice will have a softmax be taken over it