Skip to content
ml-recall

#nan

2 questions from PyTorch

Timed test

2 questions · 2 min · score and explanations at the end

Take a test
Q 1 / 2Score 0 / 0

Question 1: Single choice

hardAI-checkedPyTorch

Mathematically, f(x)=∥x∥2f(\mathbf{x}) = \lVert\mathbf{x}\rVert_2 has the gradient x/∥x∥2\mathbf{x}/\lVert\mathbf{x}\rVert_2 for x≠0\mathbf{x} \neq \mathbf{0}. What does x.grad contain after this code runs at x=0\mathbf{x} = \mathbf{0}?

x = torch.zeros(3, requires_grad=True)
f = torch.sqrt((x ** 2).sum())
f.backward()
Choose one option