mlx.core.arange

目录

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

重载函数。

  1. 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, 可选): 指定输出的数据类型。如果未指定,则当 startstopstep 中有任何一个为 float 时,默认为 float32。否则,默认为 int32

    返回

    array: 数字序列。

    注意

    遵循 Numpy 约定,实际用于生成数字的增量是 dtype(start + step) - dtype(start)。这可能导致意外结果,例如如果 start + step 是一个小数且 dtype 是整型。

  2. arange(stop : Union[int, float], step : Union[None, int, float] = None, dtype: Optional[Dtype] = None, *, stream: Union[None, Stream, Device] = None) -> array