Skip to content
← All tracks

Shapes and Strides

PyTorch

The model everything else rests on: a tensor is a buffer, a shape and a stride, and most of what looks like work is arithmetic on the last two. Where `view` succeeds, where it refuses, and why `reshape` is not a synonym.

0 / 9 solved
  1. 1. Not solved yet. Read the stride
  2. 2. Not solved yet. view refuses, reshape copies
  3. 3. Not solved yet. NCHW to NHWC, for free
  4. 4. Not solved yet. The batch of one
  5. 5. Not solved yet. Scale every row by its own weight
  6. 6. Not solved yet. Fold the heads into the batch
  7. 7. Not solved yet. The third number in a tensor
  8. 8. Not solved yet. Windows that overlap and cost nothing
  9. 9. Not solved yet. Move one axis, not all of them

Check yourself

4 questions · one attempt each

These do not count toward finishing the track. They are here to catch the things that are easy to read past.

0 / 4

After a transpose, view raises but reshape works. Why?

x.transpose(1, 2).view(-1)
x.transpose(1, 2).reshape(-1)
Question 1 of 4