flux tensoriel : : opérations : : RassemblerNd
#include <array_ops.h> Rassemblez les tranches des params dans un Tensor avec une forme spécifiée par indices .
Résumé
indices est un tenseur entier à K dimensions, mieux considéré comme un tenseur d'indices à dimensions (K-1) en params , où chaque élément définit une tranche de params :
output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]] Alors que dans tf.gather indices définit des tranches dans la première dimension de params , dans tf.gather_nd , indices définit des tranches dans les N premières dimensions de params , où N = indices.shape[-1] .
La dernière dimension des indices peut être au plus le rang des params :
indices.shape[-1] <= params.rank
La dernière dimension des indices correspond à des éléments (si indices.shape[-1] == params.rank ) ou des tranches (si indices.shape[-1] < params.rank ) le long de la dimension indices.shape[-1] de params . Le tenseur de sortie a la forme
indices.shape[:-1] + params.shape[indices.shape[-1]:]
Notez que sur le CPU, si un index hors limite est trouvé, une erreur est renvoyée. Sur GPU, si un index hors limite est trouvé, un 0 est stocké dans la valeur de sortie correspondante.
Quelques exemples ci-dessous.
Indexation simple dans une matrice :
indices = [[0, 0], [1, 1]]
params = [['a', 'b'], ['c', 'd']]
output = ['a', 'd']Découper l'indexation dans une matrice :
indices = [[1], [0]]
params = [['a', 'b'], ['c', 'd']]
output = [['c', 'd'], ['a', 'b']]Indexation dans un 3-tenseur :
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']Indexation batch dans une matrice :
indices = [[[0, 0]], [[0, 1]]]
params = [['a', 'b'], ['c', 'd']]
output = [['a'], ['b']]Indexation de tranches par lots dans une matrice :
indices = [[[1]], [[0]]]
params = [['a', 'b'], ['c', 'd']]
output = [[['c', 'd']], [['a', 'b']]]Indexation par lots dans un 3-tenseur :
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']] Voir aussi tf.gather et tf.batch_gather .
Arguments :
- scope : un objet Scope
- params : le tenseur à partir duquel collecter les valeurs.
- indices : Tenseur d’indice.
Retours :
-
Output: valeurs desparamscollectées à partir des indices donnés parindices, avec la formeindices.shape[:-1] + params.shape[indices.shape[-1]:].
Constructeurs et Destructeurs | |
|---|---|
GatherNd (const :: tensorflow::Scope & scope, :: tensorflow::Input params, :: tensorflow::Input indices) |
Attributs publics | |
|---|---|
operation | |
output | |
Fonctions publiques | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
Attributs publics
opération
Operation operation
sortir
::tensorflow::Output output
Fonctions publiques
RassemblerNd
GatherNd( const ::tensorflow::Scope & scope, ::tensorflow::Input params, ::tensorflow::Input indices )
nœud
::tensorflow::Node * node() const
opérateur :: tensorflow :: Entrée
operator::tensorflow::Input() const
opérateur :: tensorflow :: Sortie
operator::tensorflow::Output() const