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

38 lines
1.5 KiB
ReStructuredText
Raw Normal View History

2023-03-03 02:14:48 +08:00
mindspore.ops.lstsq
===================
.. py:function:: mindspore.ops.lstsq(input, A)
计算满秩矩阵 `x` :math:`(m \times n)` 与满秩矩阵 `a` :math:`(m \times k)` 的最小二乘问题或最小范数问题的解。
2023-03-08 11:16:29 +08:00
:math:`m \geq n` `lstsq` 解决最小二乘问题:
2023-03-03 02:14:48 +08:00
.. math::
\begin{array}{ll}
\min_y & \|xy-a\|_2.
\end{array}
2023-03-08 11:16:29 +08:00
:math:`m < n` `lstsq` 解决最小范数问题:
2023-03-03 02:14:48 +08:00
.. 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的第零维不相等。