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.

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

class mindspore.ops.LpNorm(axis, p=2, keep_dims=False, epsilon=1e-12)[source]

Return the p-norm of a matrix or vector.

output=inputp=(i=1n|input|p)1/p
Parameters
  • axis (int,list,tuple) – Specifies which dimension or dimensions of input to calculate the norm across.

  • p (int, optional) – The order of norm. Default: 2 .

  • keep_dims (bool, optional) – Whether the output tensors have dim retained or not. Default: False .

  • epsilon (float, optional) – The lower bound value, when the calculated norm is less than this value, replace this result with epsilon. Default: 1e-12 .

Inputs:
  • input (Tensor) - Input tensor of type float16, float32.

Outputs:

Tensor, has the same dtype as input, its shape depends on axis. For example, if the shape of input is (2,3,4), axis is [0,1], output shape will be (4,).

Raises
  • TypeError – If input is not a Tensor.

  • TypeError – If dtype of input is not one of: float16, float32.

  • TypeError – If p is not an int.

  • TypeError – If axis is not an int, a tuple or a list.

  • TypeError – If axis is a tuple or a list, but the element of axis is not an int.

  • TypeError – If keep_dims is not a bool.

  • ValueError – If the element of axis is out of the range [r,r), where r is the rank of input.

  • ValueError – If the length of shape of axis is bigger than the length of shape of input.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> input_x = Tensor(np.array([[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]]).astype(np.float32))
>>> op = ops.LpNorm(axis=[0, 1], p=2, keep_dims=False)
>>> output = op(input_x)
>>> print(output)
[ 9.165152 10.954452]