tf.keras.ops.pinv

Compute the (Moore-Penrose) pseudoinverse of a matrix.

The pseudoinverse is computed via the singular value decomposition (SVD). Singular values smaller than rcond times the largest singular value (per matrix, in the batched case) are treated as zero.

x Input tensor of shape (..., M, N).
rcond Cutoff ratio for small singular values. Singular values less than or equal to rcond * largest_singular_value are set to zero. If None (default), the backend's own default is used.

A tensor of shape (..., N, M) containing the pseudoinverse of each matrix in x.

Example:

a = keras.ops.convert_to_tensor([[1., 2.], [3., 4.], [5., 6.]])
keras.ops.pinv(a) @ a
array([[1., 0.],
       [0., 1.]], dtype=float32)