텐서플로우:: ops:: GatherNd

#include <array_ops.h>

params 에서 슬라이스를 모아 indices 로 지정된 모양의 텐서 로 만듭니다 .

요약

indices 는 K차원 정수 텐서이며, params 에 대한 인덱스의 (K-1)차원 텐서로 생각하는 것이 가장 좋습니다. 여기서 각 요소는 params 의 슬라이스를 정의합니다.

output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]]

tf.gather 에서 indices params 의 첫 번째 차원에 대한 슬라이스를 정의하는 반면, tf.gather_nd 에서 indices params 의 첫 번째 N 차원에 대한 슬라이스를 정의합니다. 여기서 N = indices.shape[-1] 입니다.

indices 의 마지막 차원은 최대 params 의 차수일 수 있습니다.

indices.shape[-1] <= params.rank

indices 의 마지막 차원은 params 의 indices.shape[-1] == params.rank 인 경우) 또는 슬라이스( indices.shape[-1] indices.shape[-1] < params.rank 인 경우)에 해당합니다. 출력 텐서의 모양은 다음과 같습니다.

indices.shape[:-1] + params.shape[indices.shape[-1]:]

참고로, CPU 환경에서는 인덱스 범위를 벗어난 경우 오류가 반환됩니다. GPU 환경에서는 인덱스 범위를 벗어난 경우 해당 출력 값에 0이 저장됩니다.

아래에 몇 가지 예를 들어보겠습니다.

행렬에 대한 간단한 인덱싱:

    indices = [[0, 0], [1, 1]]
    params = [['a', 'b'], ['c', 'd']]
    output = ['a', 'd']

행렬의 슬라이스 인덱싱:

    indices = [[1], [0]]
    params = [['a', 'b'], ['c', 'd']]
    output = [['c', 'd'], ['a', 'b']]

3차원 텐서에 대한 인덱싱:

    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']

행렬로 일괄 인덱싱:

    indices = [[[0, 0]], [[0, 1]]]
    params = [['a', 'b'], ['c', 'd']]
    output = [['a'], ['b']]

매트릭스로의 일괄 슬라이스 인덱싱:

    indices = [[[1]], [[0]]]
    params = [['a', 'b'], ['c', 'd']]
    output = [[['c', 'd']], [['a', 'b']]]

3차원 텐서로 일괄 인덱싱:

    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']]

tf.gather 및 tf.batch_gather 도 참조하십시오.

논거:

  • 범위: Scope 객체
  • params: 값을 가져올 텐서입니다.
  • 인덱스: 인덱스 텐서.

보고:

  • Output : indices.shape[:-1] + params.shape[indices.shape[-1]:] 형태를 가진 indices 에서 가져온 params 의 값.

생성자와 소멸자

GatherNd (const :: tensorflow::Scope & scope, :: tensorflow::Input params, :: tensorflow::Input indices)

공개 속성

operation
output

공공 기능

node () const
::tensorflow::Node *
operator::tensorflow::Input () const
operator::tensorflow::Output () const

공개 속성

작업

Operation operation

산출

::tensorflow::Output output

공공 기능

GatherNd

 GatherNd(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input params,
  ::tensorflow::Input indices
)

마디

::tensorflow::Node * node() const 

연산자::텐서플로우::입력

 operator::tensorflow::Input() const 

연산자::텐서플로우::출력

 operator::tensorflow::Output() const