Solved by Isaac_Kargar in post #20 
              
              
                I modified your code to this in the for loop: 
        label=torch.tensor([[0, 0, 0], [0, 1, 0], [0, 0, 2]])
		output=torch.randn(3, 3, requires_grad=True)
		loss=criterion(output, label.float())

And it works. 
If you want to do classification you need to use cross entropy loss. Remember to check s…