with this function:
def getBack(var_grad_fn):
print(var_grad_fn)
for n in var_grad_fn.next_functions:
if n[0]:
try:
tensor = getattr(n[0], ‘variable’)
print(n[0])
print(‘Tensor with grad found:’, tensor)
print(’ - gradient:’, tensor.grad)
print()
except AttributeError as e:
getBack(n[0])
I got:
<SmoothL1LossBackward object at 0x00000085E8839280>
<GatherBackward object at 0x00000085E88393D0>
<AddBackward0 object at 0x00000085E8839400>
<SubBackward0 object at 0x00000085E8839370>
<AddmmBackward object at 0x00000085E8839490>
<AccumulateGrad object at 0x00000085E8839550>
Tensor with grad found: Parameter containing:
tensor([0., 0.], requires_grad=True)

gradient: tensor([ 0.4975, -0.4975])

<TanhBackward object at 0x00000085E8839580>
<AddmmBackward object at 0x00000085E8839670>
<AccumulateGrad object at 0x00000085E8839700>
Tensor with grad found: Parameter containing:
tensor([0.], requires_grad=True)

gradient: tensor([-0.0098])

<TBackward object at 0x00000085E88396D0>
<AccumulateGrad object at 0x00000085E8839730>
Tensor with grad found: Parameter containing:
tensor([[1., 1., 1.]], requires_grad=True)

gradient: tensor([[-0.0098, -0.0098, -0.0098]])

<TBackward object at 0x00000085E88395B0>
<AccumulateGrad object at 0x00000085E8839670>
Tensor with grad found: Parameter containing:
tensor([[1.],
[1.]], requires_grad=True)

gradient: tensor([[ 0.4951],
[-0.4951]])

<MeanBackward1 object at 0x00000085E88394C0>
<AddmmBackward object at 0x00000085E88395B0>
<AccumulateGrad object at 0x00000085E8839550>
Tensor with grad found: Parameter containing:
tensor([0., 0.], requires_grad=True)

gradient: tensor([ 0.4975, -0.4975])

<TanhBackward object at 0x00000085E8839580>
<AddmmBackward object at 0x00000085E88396D0>
<AccumulateGrad object at 0x00000085E8839700>
Tensor with grad found: Parameter containing:
tensor([0.], requires_grad=True)

gradient: tensor([-0.0098])

<TBackward object at 0x00000085E8839730>
<AccumulateGrad object at 0x00000085E8839790>
Tensor with grad found: Parameter containing:
tensor([[1., 1., 1.]], requires_grad=True)

gradient: tensor([[-0.0098, -0.0098, -0.0098]])

<TBackward object at 0x00000085E8839670>
<AccumulateGrad object at 0x00000085E88396D0>
Tensor with grad found: Parameter containing:
tensor([[1.],
[1.]], requires_grad=True)

gradient: tensor([[ 0.4951],
[-0.4951]])

<AddmmBackward object at 0x00000085E8839460>
<AccumulateGrad object at 0x00000085E88394C0>
Tensor with grad found: Parameter containing:
tensor([0.], requires_grad=True)

gradient: tensor([-0.9951])

<TanhBackward object at 0x00000085E88394F0>
<AddmmBackward object at 0x00000085E88395E0>
<AccumulateGrad object at 0x00000085E8839550>
Tensor with grad found: Parameter containing:
tensor([0.], requires_grad=True)

gradient: tensor([-0.0098])

<TBackward object at 0x00000085E88396A0>
<AccumulateGrad object at 0x00000085E88396D0>
Tensor with grad found: Parameter containing:
tensor([[1., 1., 1.]], requires_grad=True)

gradient: tensor([[-0.0098, -0.0098, -0.0098]])

<TBackward object at 0x00000085E8839490>
<AccumulateGrad object at 0x00000085E88395E0>
Tensor with grad found: Parameter containing:
tensor([[1.]], requires_grad=True)

gradient: tensor([[-0.9901]])

doesnt help a lot