Solved by ptrblck in post #9 
              
              
                Just to make sure, you are running this code and get a constant loss? 
Which PyTorch version are you using? If you are using an older version (< 0.4.0), could you wrap your tensors into Variables and run it again?