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.cond

View Source On Gitee
mindspore.ops.cond(A, p=None)[source]

Returns the matrix norm or vector norm of a given tensor.

p is the calculation mode of norm. The following norm modes are supported.

p

norm for matrices

norm for vectors

None (default)

2-norm (see below)

2-norm (see below)

'fro'

Frobenius norm

– not supported –

'nuc'

nuclear norm

– not supported –

inf

max(sum(abs(x),dim=1))

max(abs(x))

-inf

min(sum(abs(x),dim=1))

min(abs(x))

0

– not supported –

sum(x!=0)

1

max(sum(abs(x),dim=0))

as below

-1

min(sum(abs(x),dim=0))

as below

2

largest singular value

as below

-2

smallest singular value

as below

other int or float

– not supported –

sum(abs(x)p)(1/p)

Note

Currently, complex numbers are not supported.

Parameters
  • A (Tensor) – Tensor of shape (,n) or (,m,n) where is zero or more batch dimensions.

  • p (Union[int, float, inf, -inf, 'fro', 'nuc'], optional) – norm's mode. Refer to the table above for behavior. Default: None.

Returns

Tensor, the result of norm calculation on the specified dimension, dim, has the same dtype as A.

Raises
  • TypeError – If A is a vector and p is a str.

  • ValueError – If A is a matrices and p is not in valid mode.

  • ValueError – If A is a matrix and p is an integer that is not in [1, -1, 2, -2].

Supported Platforms:

GPU CPU

Examples

>>> import mindspore as ms
>>> x = ms.Tensor([[1.0, 0.0, -1.0], [0.0, 1.0, 0.0], [1.0, 0.0, 1.0]])
>>> print(ms.ops.cond(x))
1.4142
>>> print(ms.ops.cond(x, 'fro'))
3.1622777