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)
Discussion 0
Join free to post in the discussion.
Related questions
- Dropout after eval()Machine Learning Engineer
- Different results every inference runMachine Learning Engineer
- Training loop without zero_gradMachine Learning Engineer
- Softmax before CrossEntropyLossMachine Learning Engineer
- Shape after a batched matmulMachine Learning Engineer
- view() after a transposeMachine Learning Engineer