Skip to content
ml-recall

#sequence-mask

1 question from PyTorch

Timed test

1 question · 1 min · score and explanations at the end

Take a test
Q 1 / 1Score 0 / 0

Question 1: Single choice

mediumAI-checkedPyTorch

Tensor Puzzle 14 keeps values[r, c] when c < length[r] and sets it to 0 otherwise.

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

def where(q, a, b):
    return (q * a) + (~q) * b

values = torch.ones(3, 4, dtype=torch.long)
length = torch.tensor([1, 3, 0])

Which line computes it correctly?

Choose one option