Skip to content
ml-recall

#contiguous

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

Multi-head attention ends by merging the heads back into one dimension:

b, num_tokens, num_heads, head_dim = 2, 6, 3, 4
context = torch.randn(b, num_heads, num_tokens, head_dim)   # attn_weights @ values
out = context.transpose(1, 2).view(b, num_tokens, num_heads * head_dim)

What happens on the last line?

Choose one option