a = torch.tensor([4.], requires_grad=True)

print(a)

b = a.pow(3)

print(b)

b.backward()

print(a.grad)

tensor([4.], requires_grad=True)

tensor([64.], grad_fn=)

tensor([48.])

is the a.grad=3?

a = torch.tensor([4.], requires_grad=True)

print(a)

b = a.pow(3)

print(b)

b.backward()

print(a.grad)

tensor([4.], requires_grad=True)

tensor([64.], grad_fn=)

tensor([48.])

is the a.grad=3?

Not sure what exactly the question is. But, read `a.grad`

as the derivative of `b`

with respect to `a`

which in this case is `3*(4^2) = 48`

.

I was just wanting to reply the same. Agree with you!

1 Like