Skip to content
ml-recall

#tensor-puzzles

13 questions from PyTorch

Timed test

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

Take a test
Q 1 / 13Score 0 / 0

Question 1: Short answer

mediumAI-checkedPyTorch

Tensor Puzzle 2 asks for the sum of a vector without calling sum. What is s.shape?

def arange(i):
    return torch.tensor(range(i))

def ones(i):
    return arange(i) * 0 + 1

a = torch.tensor([3, 1, 4, 1])
s = a @ ones(4)[:, None]

A shape in parentheses, e.g. (5,) or (5, 6)