Project DelphiTensors Workshop

Unfolding

Unfolding — rearranging a tensor into a matrix. Spanish: desplegado. Move axis k to the front, then flatten everything else into one long axis.

def unfold(T, axis): return np.moveaxis(T, axis, 0).reshape(T.shape[axis], -1) unfold(photo, 0).shape # (512, 1536) — rows are the height axis unfold(photo, 2).shape # (3, 262144) — rows are the 3 colour channels

Unfolding loses nothing. It only rearranges. Every matrix tool you know, SVD included, now applies.