23/23
Part 6 of 6 · One decode step, and long linesCheck yourself
Check yourself
6 questions
  1. 1.x is (B, T, C) and you need (B, H, T, d) heads. Which line is right?

  2. 2.y is the (B, H, T, d) output of att @ v. What does y.transpose(1, 2).view(B, T, C) do?

  3. 3.allowed = torch.tril(torch.ones(3, 3, dtype=torch.bool)). What does att.masked_fill(allowed, float('-inf')).softmax(dim=-1) give?

  4. 4.qkv is (B, T, 3C) with C = 64. Which call gives q, k and v, each (B, T, C)?

  5. 5.logits is (B, T, V). Which gives a (B, 1) tensor of greedy ids to append to idx?

  6. 6.lin = nn.Linear(512, 1536) and x is (8, 128, 512). What are lin.weight.shape and lin(x).shape?

Now the problem this lesson builds to: 28 Tensor shapes for attention (PyTorch)Practice it