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

41 lines
2.6 KiB
ReStructuredText
Raw 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) - 要计算的矩阵。支持数据类型为float32或float64。shape为 :math:`(*, M, N)` ,其中*为零或多个批量维度。
- hermitian为True时暂不支持多个批量维度。
关键字参数:
- **atol** (float, Tensor) - 绝对公差值。默认值None。
- **rtol** (float, Tensor) - 相对公差值。默认值None。
- **hermitian** (bool) - 为True时求解x为实对称的矩阵。默认值False。
输出:
- **output** (Tensor): 类型与输入相同。shape为 :math:`(*, N, M)` ,其中*为零或多个批量维度。
异常:
- **TypeError** - `hermitian` 不是bool。
- **TypeError** - `x` 不是Tensor。
- **ValueError** - `x` 的维度小于2。