mindspore/docs/api/api_python/ops/mindspore.ops.func_pinv.rst

34 lines
2.3 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.pinv
=========================
.. py:function:: mindspore.ops.pinv(x, *, atol=None, rtol=None, hermitian=False)
计算矩阵的伪逆Moore-Penrose
本函数通过SVD计算。如果 :math:`x=U*S*V^{T}` 则x的伪逆为 :math:`x^{+}=V*S^{+}*U^{T}` :math:`S^{+}` 为对S的对角线上的每个非零元素取倒数零保留在原位。
支持批量矩阵。若x是批量矩阵当atol或rtol为float时则输出具有相同的批量维度。
若atol或rtol为tensor则其shape必须可广播到 `x.svd() <https://www.mindspore.cn/docs/zh-CN/master/api_python/ops/mindspore.ops.svd.html>`_ 返回的奇异值的shape。
若x.shape为 :math:`(B, M, N)` atol或rtol的shape为 :math:`(K, B)` 则输出shape为 :math:`(K, B, N, M)`
当hermitian为True时暂时仅支持实数域默认输入x为实对称矩阵因此不会在内部检查x并且在计算中仅使用下三角部分。
当x的奇异值或特征值范数hermitian=True小于阈值 :math:`max(atol, \sigma \cdot rtol)` :math:`\sigma` 为最大奇异值或特征值)时,将其置为零,且在计算中不使用。
若rtol和atol均未指定并且x的shape(M, N)则rtol设置为 :math:`rtol=max(M, N)*\varepsilon` :math:`\varepsilon` 为x.dtype的 `eps值 <https://www.mindspore.cn/docs/zh-CN/master/api_python/ops/mindspore.ops.Eps.html>`_
若rtol未指定且atol指定值大于零则rtol设置为零。
.. note::
该函数在内部使用 `svd <https://www.mindspore.cn/docs/zh-CN/master/api_python/ops/mindspore.ops.svd.html>`_
(或 `eigh <https://www.mindspore.cn/docs/zh-CN/master/api_python/scipy/mindspore.scipy.linalg.eigh.html>`_ , `hermitian=True`
所以和这些函数具有相同问题详细信息请参阅svd()和eigh()中的警告。
参数:
- **x** (Tensor) - 输入tensor。shape为 :math:`(*, M, N)` ,其中*为零或多个批量维度。 `hermitian```True`` 时,暂不支持多个批量维度。
关键字参数:
- **atol** (float, Tensor) - 绝对容差值。默认 ``None``
- **rtol** (float, Tensor) - 相对容差值。默认 ``None``
- **hermitian** (bool) - 是否求解x为实对称的矩阵。默认 ``False``
输出:
一个shape为 :math:`(*, N, M)` 的tensor。