Solved by ptrblck in post #2 
              
              
                It seems your target is currently one-hot encoded. 
If you are using nn.NLLLoss, the target is expected to contain the class indices instead (without the channel dimension). 
In case your current target shape is [batch_size, c, h, w], try to convert it using: 
target = torch.argmax(target, 1)
loss =…