2022-05-12 11:33:48 +08:00
|
|
|
|
mindspore.ops.svd
|
|
|
|
|
|
==================
|
|
|
|
|
|
|
|
|
|
|
|
.. py:function:: mindspore.ops.svd(a, full_matrices=False, compute_uv=True)
|
|
|
|
|
|
|
|
|
|
|
|
计算单个或多个矩阵的奇异值分解。
|
|
|
|
|
|
|
2022-05-16 16:55:57 +08:00
|
|
|
|
设矩阵 :math:`A` ,svd返回奇异值 :math:`S` 、左奇异向量 :math:`U` 和右奇异向量 :math:`V` 。满足以下公式:
|
2022-05-12 11:33:48 +08:00
|
|
|
|
|
|
|
|
|
|
.. math::
|
|
|
|
|
|
A=U*diag(S)*V^{T}
|
|
|
|
|
|
|
|
|
|
|
|
**参数:**
|
|
|
|
|
|
|
2022-05-16 16:55:57 +08:00
|
|
|
|
- **a** (Tensor) - 待分解的矩阵。shape为 :math:`(*, M, N)` 。
|
|
|
|
|
|
- **full_matrices** (bool, optional) - 如果这个参数为True,则计算完整的 :math:`U` 和 :math:`V` 。否则 :math:`U` 和 :math:`V` 的shape和P有关,P是M和N的较小值, M和N是输入矩阵的行和列。默认值:False。
|
|
|
|
|
|
- **compute_uv** (bool, optional) - 如果这个参数为True,则计算 :math:`U` 和 :math:`V` , 否则只计算 :math:`S` 。默认值:True。
|
2022-05-12 11:33:48 +08:00
|
|
|
|
|
|
|
|
|
|
**返回:**
|
|
|
|
|
|
|
2022-05-16 16:55:57 +08:00
|
|
|
|
- **s** (Tensor) - 奇异值。shape为 :math:`(*, P)` 。
|
2022-05-31 10:06:10 +08:00
|
|
|
|
- **u** (Tensor) - 左奇异向量。如果compute_uv为False,该值不会返回。shape为 :math:`(*, M, P)` 。如果full_matrices为true,则shape为 :math:`(*, M, M)` 。
|
|
|
|
|
|
- **v** (Tensor) - 右奇异向量。如果compute_uv为False,该值不会返回。shape为 :math:`(*, P, N)` 。如果full_matrices为true,则shape为 :math:`(*, N, N)` 。
|
2022-05-12 11:33:48 +08:00
|
|
|
|
|
|
|
|
|
|
**异常:**
|
|
|
|
|
|
|
|
|
|
|
|
- **TypeError** - `full_matrices` 或 `compute_uv` 不是bool类型。
|
|
|
|
|
|
- **TypeError** - 输入的rank小于2。
|
|
|
|
|
|
- **TypeError** - 输入的数据类型不为float32或float64。
|