Google I/O에 참여해 주셔서 감사합니다. 주문형 모든 세션 보기 주문형 시청

tensorflow :: ops :: GatherNd

#include <array_ops.h>

indices 지정된 모양을 사용하여 params 슬라이스를 Tensor수집 합니다.

요약

indices 는 K- 차원 정수 텐서로, 각 요소가 params 조각을 정의하는 (K-1) 차원의 인덱스 텐서를 params 로 가장 잘 생각합니다.

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

반면에 tf.gather indices 로 정의 슬라이스 axis 의 치수 params 에서 tf.gather_nd , indices 처음에 정의 슬라이스 N 치수 params , 여기서 N = indices.shape[-1] .

indices 의 마지막 차원은 최대 params 순위

indices.shape[-1] <= params.rank
이 될 수 있습니다.

indices 의 마지막 차원은 params 차원 indices.shape[-1] 을 따라 요소 ( indices.shape[-1] == params.rank ) 또는 슬라이스 ( 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.gathertf.batch_gather 도 참조하십시오.

인수 :

  • 범위 : 범위 개체
  • params : 값을 수집 할 텐서입니다.
  • 인덱스 : 인덱스 텐서.

보고:

  • Output :의 값 params 주어진 인덱스에서 수집 indices , 형상과 indices.shape[:-1] + params.shape[indices.shape[-1]:] .

생성자와 소멸자

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 

연산자 :: tensorflow :: 입력

 operator::tensorflow::Input() const 

연산자 :: tensorflow :: 출력

 operator::tensorflow::Output() const