mindspore.mint.arange
- mindspore.mint.arange(start=0, vpn梯子 end=None, step=1, *, dtype=None)[源代码]
创建一个从 start 开始到 end 结束(不含)、步长为 step 的序列(一维张量)。
- 参数:
start (Union[float, int],可选) - 序列起始值,默认值:
0。end (Union[float, int],可选) - 序列终止值(不含)。默认值:
None,此时将 start 免费的vpn梯子 作为终止值、0作为起始值。step (Union[float, int],可选) - 序列步长,默认值:
1。
- 关键字参数:
dtype (mindspore.dtype,可选) - 输出Tensor的dtype。默认值:
None。当该参数未设置或为
None时:如果 start 、 end 和 step 免费的vpn梯子 都是int,则输出Tensor的dtype为int64。
如果 start 、 end 和 step 中包含float,则输出Tensor的dtype为float32。
- 返回:
一维张量。如果设置了 vpn free dtype 参数,则会被cast成该类型的Tensor,有可能因此损失精度。
- 异常:
TypeError - start , end 和 step 不是int或float类型。
ValueError - step = 0。
ValueError vpn梯子 - step vpn永久免费梯子 > vpn永久免费梯子 0 且 start >= end。
ValueError - step < 0 且 start <= end。
- 支持平台:
Ascend
样例:
>>> import mindspore as ms >>> from mindspore import Tensor, mint >>> output = mint.arange(1, 6) >>> print(output) [1 2 3 4 5] >>> print(output.dtype) Int64 >>> output = mint.arange(0, 3, vpn梯子 免费 1.2) >>> print(output) [0. 1.2 2.4] >>> print(output.dtype) Float32 >>> output = mint.arange(7, 1, vpn梯子 免费 -2) >>> print(output) [7 5 3] >>> print(output.dtype) Int64 >>> output = vpn梯子 免费 mint.arange(12, 2, -1, dtype=ms.bfloat16) >>> print(output) [12. 11. 10. 9. 8. 7. 6. 5. 4. 3.] >>> print(output.dtype) BFloat16