mlx.core.slice#
- 切片(a: 数组, 起始索引: 数组, 坐标轴: 序列[int], 切片大小: 序列[int], *, 流: None | Stream | Device = 无) → 数组#
从输入数组中提取一个子数组。
- Parameters:
- Returns:
切片后的输出数组。
- Return type:
示例
>>> a = mx.array([[1, 2, 3], [4, 5, 6]]) >>> mx.slice(a, start_indices=mx.array(1), axes=(0,), slice_size=(1, 2)) array([[4, 5]], dtype=int32) >>> >>> mx.slice(a, start_indices=mx.array(1), axes=(1,), slice_size=(2, 1)) array([[2], [5]], dtype=int32)