컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
텐서플로우:: 작전:: 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
의 첫 번째 차원으로 슬라이스를 정의하는 반면, 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
의 값.
공개 속성
공공 기능
마디
::tensorflow::Node * node() const
operator::tensorflow::Input() const
연산자::텐서플로우::출력
operator::tensorflow::Output() const
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[],[],null,["# tensorflow::ops::GatherNd Class Reference\n\ntensorflow::ops::GatherNd\n=========================\n\n`#include \u003carray_ops.h\u003e`\n\n[Gather](/versions/r2.0/api_docs/cc/class/tensorflow/ops/gather#classtensorflow_1_1ops_1_1_gather) slices from `params` into a [Tensor](/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) with shape specified by `indices`.\n\nSummary\n-------\n\n`indices` is a K-dimensional integer tensor, best thought of as a (K-1)-dimensional tensor of indices into `params`, where each element defines a slice of `params`: \n\n```scdoc\noutput[\\\\(i_0, ..., i_{K-2}\\\\)] = params[indices[\\\\(i_0, ..., i_{K-2}\\\\)]]\n```\n\n\u003cbr /\u003e\n\nWhereas in `tf.gather``indices` defines slices into the first dimension of `params`, in `tf.gather_nd`, `indices` defines slices into the first `N` dimensions of `params`, where `N = indices.shape[-1]`.\n\nThe last dimension of `indices` can be at most the rank of `params`: \n\n```text\nindices.shape[-1] \u003c= params.rank\n```\n\n\u003cbr /\u003e\n\nThe last dimension of `indices` corresponds to elements (if `indices.shape[-1] == params.rank`) or slices (if `indices.shape[-1] \u003c params.rank`) along dimension `indices.shape[-1]` of `params`. The output tensor has shape \n\n```cplint\nindices.shape[:-1] + params.shape[indices.shape[-1]:]\n```\n\n\u003cbr /\u003e\n\nNote that on CPU, if an out of bound index is found, an error is returned. On GPU, if an out of bound index is found, a 0 is stored in the corresponding output value.\n\nSome examples below.\n\nSimple indexing into a matrix:\n\n\n```text\n indices = [[0, 0], [1, 1]]\n params = [['a', 'b'], ['c', 'd']]\n output = ['a', 'd']\n```\n\n\u003cbr /\u003e\n\nSlice indexing into a matrix:\n\n\n```text\n indices = [[1], [0]]\n params = [['a', 'b'], ['c', 'd']]\n output = [['c', 'd'], ['a', 'b']]\n```\n\n\u003cbr /\u003e\n\nIndexing into a 3-tensor:\n\n\n```text\n indices = [[1]]\n params = [[['a0', 'b0'], ['c0', 'd0']],\n [['a1', 'b1'], ['c1', 'd1']]]\n output = [[['a1', 'b1'], ['c1', 'd1']]]\n```\n\n\u003cbr /\u003e\n\n\n```text\n indices = [[0, 1], [1, 0]]\n params = [[['a0', 'b0'], ['c0', 'd0']],\n [['a1', 'b1'], ['c1', 'd1']]]\n output = [['c0', 'd0'], ['a1', 'b1']]\n```\n\n\u003cbr /\u003e\n\n\n```text\n indices = [[0, 0, 1], [1, 0, 1]]\n params = [[['a0', 'b0'], ['c0', 'd0']],\n [['a1', 'b1'], ['c1', 'd1']]]\n output = ['b0', 'b1']\n```\n\n\u003cbr /\u003e\n\nBatched indexing into a matrix:\n\n\n```text\n indices = [[[0, 0]], [[0, 1]]]\n params = [['a', 'b'], ['c', 'd']]\n output = [['a'], ['b']]\n```\n\n\u003cbr /\u003e\n\nBatched slice indexing into a matrix:\n\n\n```text\n indices = [[[1]], [[0]]]\n params = [['a', 'b'], ['c', 'd']]\n output = [[['c', 'd']], [['a', 'b']]]\n```\n\n\u003cbr /\u003e\n\nBatched indexing into a 3-tensor:\n\n\n```text\n indices = [[[1]], [[0]]]\n params = [[['a0', 'b0'], ['c0', 'd0']],\n [['a1', 'b1'], ['c1', 'd1']]]\n output = [[[['a1', 'b1'], ['c1', 'd1']]],\n [[['a0', 'b0'], ['c0', 'd0']]]]\n```\n\n\u003cbr /\u003e\n\n\n```text\n indices = [[[0, 1], [1, 0]], [[0, 0], [1, 1]]]\n params = [[['a0', 'b0'], ['c0', 'd0']],\n [['a1', 'b1'], ['c1', 'd1']]]\n output = [[['c0', 'd0'], ['a1', 'b1']],\n [['a0', 'b0'], ['c1', 'd1']]]\n```\n\n\u003cbr /\u003e\n\n\n```text\n indices = [[[0, 0, 1], [1, 0, 1]], [[0, 1, 1], [1, 1, 0]]]\n params = [[['a0', 'b0'], ['c0', 'd0']],\n [['a1', 'b1'], ['c1', 'd1']]]\n output = [['b0', 'b1'], ['d0', 'c1']]\n```\n\n\u003cbr /\u003e\n\nSee also `tf.gather` and `tf.batch_gather`.\n\nArguments:\n\n- scope: A [Scope](/versions/r2.0/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- params: The tensor from which to gather values.\n- indices: Index tensor.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.0/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): Values from `params` gathered from indices given by `indices`, with shape `indices.shape[:-1] + params.shape[indices.shape[-1]:]`.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [GatherNd](#classtensorflow_1_1ops_1_1_gather_nd_1a83ac49d5f8899faa1cf24f7eea2c01ac)`(const ::`[tensorflow::Scope](/versions/r2.0/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` params, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices)` ||\n\n| ### Public attributes ||\n|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_gather_nd_1a3ef794c722311cc2b178e09e32c48f15) | [Operation](/versions/r2.0/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_gather_nd_1a3e99a0c52482bb14c94c1bbf9b507e95) | `::`[tensorflow::Output](/versions/r2.0/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public functions ||\n|---------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_gather_nd_1ab32d5802ad22d9fa803952390ca3fce8)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_gather_nd_1ab8601c2824b77c2f890a973ccd8f7212)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_gather_nd_1a7741e14bd7240a514268290545b62223)`() const ` | ` ` ` ` |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### output\n\n```text\n::tensorflow::Output output\n``` \n\nPublic functions\n----------------\n\n### GatherNd\n\n```gdscript\n GatherNd(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input params,\n ::tensorflow::Input indices\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n```"]]