Hello,  I’m still fairly new to pytorch, trying to understand autograd.  I am using L1 loss to keep things simple, which results in a loss value as expected.  But the gradient is not as expected.  Using L1 loss in my old framework meant the initial gradients were just output-targets.  However pytorch is giving fixed values of .25*direction:
grad_output during backward_hook of top layer with 2 nodes and a batch size of 2:
(Variable containing:
(0 ,0 ,.,.) = 
  0.2500

(0 ,1 ,.,.) = 
 -0.2500

(1 ,0 ,.,.) = 
  0.2500

(1 ,1 ,.,.) = 
 -0.2500
[torch.cuda.FloatTensor of size 2x2x1x1 (GPU 0)]
,)

Output:
Variable containing:
 0.5952  0.3170
 0.5666  0.6178
[torch.cuda.FloatTensor of size 2x2 (GPU 0)]

Targets:
(Pdb) targets
Variable containing:
 0  1
 0  1
[torch.cuda.LongTensor of size 2x2 (GPU 0)]

Loss is as expected:
(Pdb) (output-targets).abs().mean()
Variable containing:
 0.5567
[torch.cuda.FloatTensor of size 1 (GPU 0)]

(Pdb) loss
Variable containing:
 0.5567
[torch.cuda.FloatTensor of size 1 (GPU 0)]