mindspore/docs/api/api_python/mint/mindspore.mint.func_arange.rst

30 lines
1.4 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.mint.arange
=====================
.. py:function:: mindspore.mint.arange(start=0, end=None, step=1, *, dtype=None)
创建一个从 `start` 开始到 `end` 结束(不含)、步长为 `step` 的序列(一维张量)。
参数:
- **start** (Union[float, int],可选) - 序列起始值,默认值: ``0``
- **end** (Union[float, int],可选) - 序列终止值(不含),默认值: ``None`` ,如果是 ``None`` ,则将 `start` 作为终止值, ``0`` 为起始值。
- **step** (Union[float, int],可选) - 序列步长,默认值: ``1``
关键字参数:
- **dtype** (mindspore.dtype可选) - 输出Tensor的dtype。默认值 ``None``
当该参数未设置或为 ``None`` 时:
如果 `start``end``step` 都是int则输出Tensor的dtype为int64。
如果 `start``end``step` 中包含float则输出Tensor的dtype为float32。
返回:
一维张量,如果设置了 `dtype` 参数则会被cast成该类型的Tensor有可能因此损失精度。
异常:
- **TypeError** - `start` `end``step` 不是int或float类型。
- **ValueError** - `step` = 0。
- **ValueError** - `step` > 0 且 `start` >= `end`
- **ValueError** - `step` < 0 且 `start` <= `end`