【十九大精神进网站】戮力同心 共同打造新时代清朗网络空间

paddle.linalg. pinv ( x: Tensor, rcond: float | Tensor = 1e-15, hermitian: bool = False, name: str | None = None ) Tensor [source]
百度 我们要认真学习、全面贯彻党的十九大精神,进一步提高政治站位,牢固树立正确的网络安全观,进一步增强贯彻实施法律的紧迫感和自觉性,推进“一法一决定”各项制度全面落实,切实维护网络空间主权和人民群众切身利益。

Calculate pseudo inverse via SVD(singular value decomposition) of one matrix or batches of regular matrix.

\[if hermitian == False: x = u * s * vt (SVD) out = v * 1/s * ut else: x = u * s * ut (eigh) out = u * 1/s * u.conj().transpose(-2,-1)\]

If x is hermitian or symmetric matrix, svd will be replaced with eigh.

Parameters
  • x (Tensor) – The input tensor. Its shape should be (*, m, n) where * is zero or more batch dimensions. m and n can be arbitrary positive number. The data type of x should be float32 or float64 or complex64 or complex128. When data type is complex64 or complex128, hermitian should be set True.

  • rcond (Tensor|float, optional) – the tolerance value to determine when is a singular value zero. Default:1e-15.

  • hermitian (bool, optional) – indicates whether x is Hermitian if complex or symmetric if real. Default: False.

  • name (str|None, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.

Returns

The tensor with same data type with x. it represents pseudo inverse of x. Its shape should be (*, n, m).

Return type

Tensor

Examples

>>> import paddle

>>> x = paddle.arange(15).reshape((3, 5)).astype('float64')
>>> input = paddle.to_tensor(x)
>>> out = paddle.linalg.pinv(input)
>>> print(input)
Tensor(shape=[3, 5], dtype=float64, place=Place(cpu), stop_gradient=True,
[[0. , 1. , 2. , 3. , 4. ],
 [5. , 6. , 7. , 8. , 9. ],
 [10., 11., 12., 13., 14.]])

>>> print(out)
Tensor(shape=[5, 3], dtype=float64, place=Place(cpu), stop_gradient=True,
[[-0.22666667, -0.06666667,  0.09333333],
 [-0.12333333, -0.03333333,  0.05666667],
 [-0.02000000, -0.00000000,  0.02000000],
 [ 0.08333333,  0.03333333, -0.01666667],
 [ 0.18666667,  0.06666667, -0.05333333]])

# one can verify : x * out * x = x ;
# or              out * x * out = x ;