텐서플로우:: 작전:: GatherNd
#include <array_ops.h> params 의 조각을 indices 로 지정된 모양의 Tensor 로 수집합니다 .
요약
indices 는 K차원 정수 텐서이며, params 에 대한 인덱스의 (K-1)차원 텐서로 가장 잘 생각됩니다. 여기서 각 요소는 params 조각을 정의합니다.
output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]] tf.gather indices params 의 axis 차원으로 슬라이스를 정의하는 반면, tf.gather_nd 에서 indices params 의 첫 번째 N 차원으로 슬라이스를 정의합니다. 여기서 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.gather 및 tf.batch_gather 도 참조하세요.
인수:
- 범위: 범위 개체
- 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