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

    產生數值範圍。

    step 為增量,在半開區間 [start, stop) 產生數值。

    引數:

    start(float 或 int,可選):起始值,預設為 0。stop(float 或 int):終止值。step(float 或 int,可選):增量,預設為 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