gather¶
- paddle. gather ( x, index, axis=None, name=None ) [source]
- 
         Output is obtained by gathering entries of axisofxindexed byindexand concatenate them together.Given: x = [[1, 2], [3, 4], [5, 6]] index = [1, 2] axis=[0] Then: out = [[3, 4], [5, 6]]- Parameters
- 
           - x (Tensor) – The source input tensor with rank>=1. Supported data type is int32, int64, float32, float64 and uint8 (only for CPU), float16 (only for GPU). 
- index (Tensor) – The index input tensor with rank=1. Data type is int32 or int64. 
- axis (Tensor|int, optional) – The axis of input to be gathered, it’s can be int or a Tensor with data type is int32 or int64. The default value is None, if None, the - axisis 0.
- name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name . 
 
- Returns
- 
           The output is a tensor with the same rank as x.
- Return type
- 
           output (Tensor) 
 Examples import paddle input = paddle.to_tensor([[1,2],[3,4],[5,6]]) index = paddle.to_tensor([0,1]) output = paddle.gather(input, index, axis=0) # expected output: [[1,2],[3,4]] 
