Solved by tom in post #2 
              
              
                I think this is a very cool question! 
CrossEntropyLoss consists of two things, a LogSoftmax followed by a NLLLoss (Negative Log Likelihood). 
Accordingly, there are two parts: 


If you select the the rows (you could also use x[:, class_mask] btw if you have fixed classes), the implicit (log) softm…