Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.ops.Svd

View Source On Gitee
class mindspore.ops.Svd(full_matrices=False, compute_uv=True)[source]

Computes the singular value decompositions of one or more matrices.

Refer to mindspore.ops.svd() for more details.

Parameters
  • full_matrices (bool, optional) – If True , compute full-sized U and V. If False, compute only the leading P singular vectors, with P is the minimum of M and N. Default: False .

  • compute_uv (bool, optional) – If True , compute the left and right singular vectors. If False , compute only the singular values. Default: True .

Inputs:
  • input (Tensor) - Tensor of the matrices to be decomposed. The shape should be (,M,N), the supported dtype are float32 and float64.

Outputs:
  • s (Tensor) - Singular values. The shape is (,P).

  • u (Tensor) - Left singular vectors. If compute_uv is False , u will be zero value. The shape is (,M,P). If full_matrices is True , the shape will be (,M,M).

  • v (Tensor) - Right singular vectors. If compute_uv is False , v will be zero value. The shape is (,N,P). If full_matrices is True , the shape will be (,N,N).

Supported Platforms:

GPU CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor, set_context
>>> from mindspore import ops
>>> set_context(device_target="CPU")
>>> svd = ops.Svd(full_matrices=True, compute_uv=True)
>>> a = Tensor(np.array([[1, 2], [-4, -5], [2, 1]]).astype(np.float32))
>>> s, u, v = svd(a)
>>> print(s)
[7.0652843 1.040081 ]
>>> print(u)
[[ 0.30821905 -0.48819482 0.81649697]
 [-0.90613353  0.11070572 0.40824813]
 [ 0.2896955   0.8656849  0.4082479 ]]
>>> print(v)
[[ 0.63863593 0.769509  ]
 [ 0.769509  -0.63863593]]