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

38 lines
1.5 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.lstsq
===================
.. py:function:: mindspore.ops.lstsq(input, A)
计算满秩矩阵 `x` :math:`(m \times n)` 与满秩矩阵 `a` :math:`(m \times k)` 的最小二乘问题或最小范数问题的解。
:math:`m \geq n` `lstsq` 解决最小二乘问题:
.. math::
\begin{array}{ll}
\min_y & \|xy-a\|_2.
\end{array}
:math:`m < n` `lstsq` 解决最小范数问题:
.. math::
\begin{array}{llll}
\min_y & \|y\|_2 & \text{subject to} & xy = a.
\end{array}
其中 `y` 表示返回的Tensor。
参数:
- **input** (Tensor) - 上述公式中 :math:`(m \times n)` 的矩阵 :math:`x` 输入Tensor的数据类型为float16、float32或float64。
- **A** (Tensor) - 上述公式中 :math:`(m \times k)` 的矩阵 :math:`a` 输入Tensor的数据类型为float16、float32或float64。
返回:
Tensor最小二乘问题或最小范数问题的解其shape为 :math:`(n \times k)` ,数据类型与 `input` 相同。
异常:
- **TypeError** - `input``A` 不是Tensor。
- **TypeError** - `input``A` 不是以下数据类型之一float16、float32、float64。
- **TypeError** - `input``A` 的数据类型不同。
- **ValueError** - `input` 的维度不等于2。
- **ValueError** - `A` 的维度不等于2或1。
- **ValueError** - `input``A` shape的第零维不相等。