mlx.core.arange

目錄

mlx.core.arange#

arange(start: int | float, stop: None | int | float, step: None | int | float, dtype: Dtype | None = None, *, stream: StreamOrDevice = None) → array#
arange(stop: int | float, step: None | int | float = None, dtype: Dtype | None = None, *, stream: StreamOrDevice = None) → array

多載函式。

  1. arange(start : int | float, stop : None | int | float, step : None | int | float, dtype: Dtype | None = None, *, stream: StreamOrDevice = None) -> array

    產生數值範圍。

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

    引數:

    start (float or int, optional): Starting value which defaults to 0. stop (float or int, optional): Stopping value. step (float or int, optional): Increment which defaults to 1. dtype (Dtype, optional): Specifies the data type of the output. If unspecified will default to float32 if any of start, stop, or step are float. Otherwise will default to int32, or int64 if any of start, stop, or step does not fit in int32.

    回傳:

    array:數值範圍。

    注意:

    遵循 Numpy 慣例,用於產生數值的實際增量為 dtype(start + step) - dtype(start)。這可能造成非預期結果,例如 start + step 為小數但 dtype 為整數型別時。

  2. arange(stop : int | float, step : None | int | float = None, dtype: Dtype | None = None, *, stream: StreamOrDevice = None) -> array