mindspore.ops.arange
- mindspore.ops.arange(start=0, end=None, step=1, *, dtype=None)[source]
Returns a tensor with a step length of step in the interval [ start , end ).
- Parameters
start (Union[float, int, Tensor], optional) – The start value of the interval. Default
0
.end (Union[float, int, Tensor], optional) – The end value of the interval. Default
None
represents to the value of start , and 0 is used as the start value.step (Union[float, int, Tensor], optional) – The interval between each value. Default
1
.
- Keyword Arguments
dtype (mindspore.dtype, optional) – The data type specified. Default
None
.- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> mindspore.ops.arange(4) Tensor(shape=[4], dtype=Int64, value= [0, 1, 2, 3]) >>> mindspore.ops.arange(1, 6) Tensor(shape=[5], dtype=Int64, value= [1, 2, 3, 4, 5]) >>> mindspore.ops.arange(0, 2, 0.5) Tensor(shape=[4], dtype=Float32, value= [ 0.00000000e+00, 5.00000000e-01, 1.00000000e+00, 1.50000000e+00])