๐จ The dim Collapse Visualizer
A hydraulic press squishes exactly the axis you select โ watch which one actually disappears.
๐ How To Use This Lab
Pick
dim=0
or
dim=1
โ
the press repositions to show which axis it's about to squish.
Press
๐จ Collapse!
โ
watch it physically flatten that axis, real sums appearing live.
dim=0
presses
top-to-bottom
(vertical) โ the 3 floors squish into 1.
dim=1
presses
side-to-side
(horizontal) โ the 4 columns squish into 1.
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
dim = 0
dim = 1
keepdim=False
keepdim=True
๐จ Collapse!
โบ Reset
๐จ SQUISH
Pick a dim and press Collapse โ I'll show you exactly which axis gets flattened.
๐งโ๐ซ PROF. TORCH
dim=N means "sum ALONG this axis" โ that axis is what disappears, not what survives.