GatherND
tensorflow C++ API
GGather slices from params into a Tensor with shape specified by indices.
Summary
indicesis an K-dimensional integer tensor, best thought of as a (K-1)-dimensional tensor of indices intoparams, where each element defines a slice ofparams:
output[i_0,..., i_{K-2}]=params[indices[i0,..., i_{K-2}]]
Whereas in tf.gatherindicesdefines slices into the first dimension ofparams, intf.gather_nd,indicesdefines slices into the firstNdimensions ofparams, whereN = indices.shape[-1].
The last dimension ofindicescan be at most the rank ofparams:
indices.shape[-1]<=params.rank
The last dimension ofindicescorresponds to elements (ifindices.shape[-1] == params.rank) or slices (ifindices.shape[-1] < params.rank) along dimensionindices.shape[-1]ofparams. The output tensor has shape
indices.shape[:-1]+params.shape[indices.shape[-1]:]
Some examples below.
Simple indexing into a matrix:
```python indices = [[0, 0], [1, 1]] params = [['a', 'b'], ['c', 'd']] output = ['a', 'd'] ```
Sliceindexing into a matrix:
```python indices = [[1], [0]] params = [['a', 'b'], ['c', 'd']] output = [['c', 'd'], ['a', 'b']] ```
Indexing into a 3-tensor:
```python indices = [[1]] params = [[['a0', 'b0'], ['c0', 'd0']], [['a1', 'b1'], ['c1', 'd1']]] output = [[['a1', 'b1'], ['c1', 'd1']]]
indices = [[0,1],[1,0]]
params = [[['a0','b0'],['c0','d0']],[['a1','b1'],['c1','d1']]]
output = [['c0','d0'],['a1','b1']]
indices = [[0,0,1],[1,0,1]]
params = [[['a0','b0'],['c0','d0']],[['a1','b1'],['c1','d1']]]
output = ['b0','b1']
```
Batched indexing into a matrix:
```python indices = [[[0, 0]], [[0, 1]]] params = [['a', 'b'], ['c', 'd']] output = [['a'], ['b']] ```
Batched slice indexing into a matrix:
```python indices = [[[1]], [[0]]] params = [['a', 'b'], ['c', 'd']] output = [[['c', 'd']], [['a', 'b']]] ```
Batched indexing into a 3-tensor:
```python indices = [[[1]], [[0]]] params = [[['a0', 'b0'], ['c0', 'd0']], [['a1', 'b1'], ['c1', 'd1']]] output = [[[['a1', 'b1'], ['c1', 'd1']]], [[['a0', 'b0'], ['c0', 'd0']]]]
indices = [[[0, 1], [1, 0]], [[0, 0], [1, 1]]] params = [[['a0', 'b0'], ['c0', 'd0']], [['a1', 'b1'], ['c1', 'd1']]] output = [[['c0', 'd0'], ['a1', 'b1']], [['a0', 'b0'], ['c1', 'd1']]]
indices = [[[0,0,1],[1,0,1]],[[0,1,1],[1,1,0]]]
params = [[['a0','b0'],['c0','d0']],[['a1','b1'],['c1','d1']]]
output = [['b0','b1'],['d0','c1']]
```
Arguments:
- scope: A Scope object
- params: The N-D tensor from which to gather values.
- indices: Index tensor.
Returns:
- Output: Values from- paramsgathered from indices given by- indices, with shape- indices.shape[:-1] + params.shape[indices.shape[-1]:].
GatherND block
Source link :https://github.com/EXPNUNI/enuSpaceTensorflow/blob/master/enuSpaceTensorflow/tf_array_ops.cpp

Argument:
- Scope scope : A Scope object (A scope is generated automatically each page. A scope is not connected.)
- Input params: ATensor. The N-D tensor from which to gather values.
- Input indices:ATensor. must be an integer tensor of any dimension. In the value of params index num.
Output:
- output : Output object of GatherND class object.
Result:
- std::vector(Tensor) result_output: ATensor. Has the same type asparams. Values fromparamsgathered from indices given byindices.
Using Method


※ 위의 그림처럼 params가 다 차원 일때 indices의 index에 따라 params의 값을 가져온다.