Question 1: Single choice
mediumAI-checkedPyTorchdef arange(i):
return torch.tensor(range(i))
m = torch.arange(9).reshape(3, 3) # [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
Which expression returns the diagonal tensor([0, 4, 8])?
3 questions from PyTorch
3 questions · 3 min · score and explanations at the end
def arange(i):
return torch.tensor(range(i))
m = torch.arange(9).reshape(3, 3) # [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
Which expression returns the diagonal tensor([0, 4, 8])?