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])?
1 question from PyTorch
1 question · 1 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])?