Shape Ops & Indexing
reshape, squeeze/unsqueeze, permute, and indexing: same spirit as NumPy.
| Call | Effect | Example |
|---|---|---|
| remove all size-1 dimensions | shape |
| insert a new size-1 dimension at | shape |
| reorder dimensions arbitrarily | shape |
| join along an EXISTING dimension | two |
| join along a NEW dimension | two |
⚠️ Watch out: x.view() requires contiguous memory and fails after operations like .transpose()/.permute(): use .reshape() (or call .contiguous() first) to be safe.
Now practice it
Exercises that use what this lesson just covered.