๐Ÿ”จ The dim Collapse Visualizer

A hydraulic press squishes exactly the axis you select โ€” watch which one actually disappears.

๐Ÿ“‹ How To Use This Lab
  1. Pick dim=0 or dim=1 โ†’ the press repositions to show which axis it's about to squish.
  2. Press ๐Ÿ”จ Collapse! โ†’ watch it physically flatten that axis, real sums appearing live.
  3. dim=0 presses top-to-bottom (vertical) โ€” the 3 floors squish into 1.
  4. dim=1 presses side-to-side (horizontal) โ€” the 4 columns squish into 1.
  5. Flip keepdim โ†’ see whether the squished axis survives as size-1 or vanishes completely.
(3, 4, 2)
โžœ
sum(dim=0) โ†’ (4, 2)
torch.sum(x, dim=0) โ€” press comes from the TOP
keepdim=False
keepdim=True
๐Ÿ”จ SQUISHPick a dim and press Collapse โ€” I'll show you exactly which axis gets flattened.
๐Ÿง‘โ€๐Ÿซ PROF. TORCHdim=N means "sum ALONG this axis" โ€” that axis is what disappears, not what survives.