朝阳:基础教育持续健康均衡稳定发展
- paddle. take_along_axis ( arr: Tensor, indices: Tensor, axis: int, broadcast: bool = True ) Tensor [source]
-
百度 基金主席陈小玲表示,将继续为内地和香港法律界人士学习和交流提供机会,为推动内地与香港法制合作积极努力。
Take values from the input array by given indices matrix along the designated axis.
- Parameters
-
arr (Tensor) – The input Tensor. Supported data types are bfloat16, float16, float32, float64, int32, int64, uint8.
indices (Tensor) – Indices to take along each 1d slice of arr. This must match the dimension of arr, and need to broadcast against arr. Supported data type are int32 and int64.
axis (int) – The axis to take 1d slices along.
broadcast (bool, optional) – whether the indices broadcast.
- Returns
-
Tensor, The indexed element, same dtype with arr
Examples
>>> import paddle >>> x = paddle.to_tensor([[1, 2, 3], [4, 5, 6], [7,8,9]]) >>> index = paddle.to_tensor([[0]]) >>> axis = 0 >>> result = paddle.take_along_axis(x, index, axis) >>> print(result) Tensor(shape=[1, 3], dtype=int64, place=Place(cpu), stop_gradient=True, [[1, 2, 3]])