Tensorflow :: ops :: GatherNd
#include <array_ops.h>
Sammeln Sie Scheiben von params
in einem Tensor mit einer durch indices
angegebenen Form.
Zusammenfassung
indices
ist ein K-dimensionaler ganzzahliger Tensor, der am besten als (K-1) -dimensionaler Tensor von Indizes in params
, wobei jedes Element eine params
von params
:
output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]]
Während in tf.gather
indices
Slices in die axis
von params
tf.gather_nd
, definieren indices
in tf.gather_nd
Slices in die ersten N
Dimensionen von params
, wobei N = indices.shape[-1]
.
Die letzte Dimension von indices
kann höchstens den Rang von params
:
indices.shape[-1] <= params.rank
Die letzte Dimension von indices
entspricht Elementen (wenn indices.shape[-1] == params.rank
) oder Slices (wenn indices.shape[-1] < params.rank
) entlang der Dimension indices.shape[-1]
von params
. Der Ausgangstensor hat die Form
indices.shape[:-1] + params.shape[indices.shape[-1]:]
Beachten Sie, dass auf der CPU ein Fehler zurückgegeben wird, wenn ein nicht gebundener Index gefunden wird. Wenn auf der GPU ein nicht gebundener Index gefunden wird, wird eine 0 im entsprechenden Ausgabewert gespeichert.
Einige Beispiele unten.
Einfache Indizierung in eine Matrix:
indices = [[0, 0], [1, 1]] params = [['a', 'b'], ['c', 'd']] output = ['a', 'd']
Slice-Indizierung in eine Matrix:
indices = [[1], [0]] params = [['a', 'b'], ['c', 'd']] output = [['c', 'd'], ['a', 'b']]
Indizierung in einen 3-Tensor:
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']
Batch-Indizierung in eine Matrix:
indices = [[[0, 0]], [[0, 1]]] params = [['a', 'b'], ['c', 'd']] output = [['a'], ['b']]
Indizierte Batch-Slice-Indizierung in einer Matrix:
indices = [[[1]], [[0]]] params = [['a', 'b'], ['c', 'd']] output = [[['c', 'd']], [['a', 'b']]]
Batch-Indizierung in einen 3-Tensor:
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']]
Siehe auch tf.gather
und tf.batch_gather
.
Argumente:
- scope: Ein Scope- Objekt
- params: Der Tensor, aus dem Werte gesammelt werden sollen.
- Indizes: Index-Tensor.
Kehrt zurück:
-
Output
: Werte vonparams
die aus durch Indizes angegebenenindices
mitindices.shape[:-1] + params.shape[indices.shape[-1]:]
.
Konstruktoren und Destruktoren | |
---|---|
GatherNd (const :: tensorflow::Scope & scope, :: tensorflow::Input params, :: tensorflow::Input indices) |
Öffentliche Attribute | |
---|---|
operation | |
output |
Öffentliche Funktionen | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
Öffentliche Attribute
Operation
Operation operation
Ausgabe
::tensorflow::Output output
Öffentliche Funktionen
GatherNd
GatherNd( const ::tensorflow::Scope & scope, ::tensorflow::Input params, ::tensorflow::Input indices )
Knoten
::tensorflow::Node * node() const
operator :: tensorflow :: Input
operator::tensorflow::Input() const
operator :: tensorflow :: Output
operator::tensorflow::Output() const