Lesson 11
Reshape & Flatten
Change structure, keep data:
a = np.arange(12) b = a.reshape(3, 4) b.flatten() # back to 1D
Why this matters
Models and file formats care about shape (batch Γ features, image Γ channels). Reshaping lets you reinterpret the same buffer: 1D sequence β grid β batch matricesβoften without copying when the total size matches.
Confusing reshape with transpose is a common mistake; this lesson anchors the difference.
ResourcesDocs, references & more β opens in a new tab
π― Your Task
flat = np.arange(1,13). Reshape β grid (3,4). Flatten β back_flat.
flat.reshape(3, 4) then grid.flatten()
ββ run Β· ββ β nav
βΆ Output
Run your code to see output here.