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產生數值範圍。
以
step為增量,在半開區間[start, stop)產生數值。- 引數:
start(float 或 int,可選):起始值,預設為
0。stop(float 或 int):終止值。step(float 或 int,可選):增量,預設為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