Project DelphiTensors Workshop

The Moore-Penrose pseudoinverse

A⁺ is defined for every matrix — square or not, singular or not — and it is computed from the SVD:

A = np.random.randn(5, 3) A_plus = np.linalg.pinv(A) print(A.shape, A_plus.shape) # (5, 3) (3, 5) — the shape flips U, S_, Vt = np.linalg.svd(A, full_matrices=False) np.allclose(A_plus, Vt.T @ np.diag(1/S_) @ U.T) # True

Note the shape flip: a tall matrix’s pseudoinverse is wide.