mlx.core.arange#
- arange(start: int | float, stop: int | float, step: None | int | float, dtype: Dtype | None = None, *, stream: None | Stream | Device = None) array #
- arange(stop: int | float, step: None | int | float = None, dtype: Dtype | None = None, *, stream: None | Stream | Device = None) array
重载函数。
arange(start : Union[int, float], stop : Union[int, float], step : Union[None, int, float], dtype: Optional[Dtype] = None, *, stream: Union[None, Stream, Device] = None) -> array
生成数字序列。
生成半开区间
[start, stop)
内以step
为增量的数字。- 参数
start (浮点数或整数, 可选): 起始值,默认为
0
。 stop (浮点数或整数): 停止值。 step (浮点数或整数, 可选): 增量,默认为1
。 dtype (Dtype, 可选): 指定输出的数据类型。如果未指定,则当start
、stop
或step
中有任何一个为float
时,默认为float32
。否则,默认为int32
。- 返回
array: 数字序列。
- 注意
遵循 Numpy 约定,实际用于生成数字的增量是
dtype(start + step) - dtype(start)
。这可能导致意外结果,例如如果 start + step 是一个小数且 dtype 是整型。
arange(stop : Union[int, float], step : Union[None, int, float] = None, dtype: Optional[Dtype] = None, *, stream: Union[None, Stream, Device] = None) -> array