Skip to content
RED SAGSkills
medium10 pts · first answer countspytorchautograd

Gradient of a sum of squares

What does this PyTorch code print?

import torch
x = torch.tensor([1.0, 2.0, 3.0], requires_grad=True)
y = (x ** 2).sum()
y.backward()
print(x.grad)
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions