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

View Source On Gitee
mindspore.ops.arange(start=0, end=None, step=1, *, dtype=None)[source]

Creates a sequence of numbers that begins at start and extends by increments of step up to but not including end.

Parameters
  • start (Union[float, int, Tensor], optional) – The start of the interval. If Tensor, the shape must be () . Default: 0 .

  • end (Union[float, int, Tensor], optional) – The end of the interval, exclusive. If Tensor, the shape must be (). Default: None . If None , it defaults to the value of start, and 0 is used as the starting value.

  • step (Union[float, int, Tensor], optional) – Number that increments start. If Tensor, the shape must be (). Default: 1 .

Keyword Arguments

dtype (mindspore.dtype, optional) –

The required data type of returned Tensor. Default: None . When dtype is not specified or None:

If start, end, and step are all integers, the dtype of output is int64,

If start, end, and step contain at least one floating-point number, the dtype of output is float32.

Returns

A 1-D Tensor, with the same type as the inputs.

Raises
  • TypeError – If start, end or step is not an int or a float or a TensorScalar(Special Tensor with shape ()) in valid dtypes.

  • ValueError – If step = 0.

  • ValueError – If start >= end when step > 0.

  • ValueError – If start <= end when step < 0.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore as ms
>>> from mindspore import Tensor, ops
>>> output = ops.arange(1, 6)
>>> print(output)
[1 2 3 4 5]
>>> print(output.dtype)
Int64
>>> output = ops.arange(0, 3, 1.2)
>>> print(output)
[0.  1.2 2.4]
>>> print(output.dtype)
Float32
>>> output = ops.arange(7, 1, -2)
>>> print(output)
[7 5 3]
>>> print(output.dtype)
Int64
>>> output = ops.arange(ms.Tensor(12.0, dtype=ms.float64), 2, ms.Tensor(-1.0, dtype=ms.float32))
>>> print(output)
[12. 11. 10.  9.  8.  7.  6.  5.  4.  3.]
>>> print(output.dtype)
Float32