Solved by KFrank in post #2 
              
              
                Hi Hashir! 

If I understand what you are trying to do here (and I am not at all 
sure that I do), then torch.nn.CrossEntropyLoss should do what 
you want without further manipulation.  (Look at the parts where 
the documentation talks about the “K-dimensional case.”) 
Let the output of your model b…