Solved by albanD in post #2 
              
              
                For simplicity, in pytorch, if a Variable contains a single value, var.backward() is equivalent to var.backward(torch.Tensor([1])). 
If you use the loss without reduction (to be able to use the value for each sample in your batch independently?), you get as output a Variable which contains one entry…