tensorflow :: ops :: GatherNd
#include <array_ops.h>
Gromadzić wycinki z params
w Tensor w kształcie określonym przez indices
.
streszczenie
indices
są K-wymiarowej całkowitą tensora najlepiej traktowane jako (K-1) wymiarowej tensora indeksów język params
, gdzie każdy element definiuje kawałek params
:
output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]]
Natomiast w tf.gather
indices
definiuje plastry język do axis
wymiaru params
, w tf.gather_nd
, indices
definiuje plastry do pierwszego N
wymiarów params
, gdzie N = indices.shape[-1]
.
Ostatnim wymiarem indices
może być co najwyżej rangi params
:
indices.shape[-1] <= params.rank
Ostatni wymiar indices
odpowiada elementom (jeśli indices.shape[-1] == params.rank
) lub indices.shape[-1] < params.rank
(jeśli indices.shape[-1] < params.rank
) wzdłuż wymiaru indices.shape[-1]
params
. Tensor wyjściowy ma kształt
indices.shape[:-1] + params.shape[indices.shape[-1]:]
Zwróć uwagę, że w przypadku procesora, jeśli zostanie znaleziony poza powiązanym indeksem, zwracany jest błąd. Na GPU, jeśli zostanie znaleziony indeks poza zakresem, w odpowiedniej wartości wyjściowej zostanie zapisana wartość 0.
Kilka przykładów poniżej.
Proste indeksowanie do macierzy:
indices = [[0, 0], [1, 1]] params = [['a', 'b'], ['c', 'd']] output = ['a', 'd']
Indeksowanie wycinków do macierzy:
indices = [[1], [0]] params = [['a', 'b'], ['c', 'd']] output = [['c', 'd'], ['a', 'b']]
Indeksowanie do 3-tensora:
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']
Indeksowanie wsadowe do macierzy:
indices = [[[0, 0]], [[0, 1]]] params = [['a', 'b'], ['c', 'd']] output = [['a'], ['b']]
Indeksowanie podzielonych plasterków na macierz:
indices = [[[1]], [[0]]] params = [['a', 'b'], ['c', 'd']] output = [[['c', 'd']], [['a', 'b']]]
Indeksowanie zbiorcze w 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']]
Zobacz także tf.gather
i tf.batch_gather
.
Argumenty:
- zakres: obiekt Scope
- params: tensor, z którego mają być zbierane wartości.
- indeksy: tensor indeksów.
Zwroty:
-
Output
: Wartości zparams
zebranych z indeksami podanymi przezindices
z kształtuindices.shape[:-1] + params.shape[indices.shape[-1]:]
.
Konstruktorzy i niszczyciele | |
---|---|
GatherNd (const :: tensorflow::Scope & scope, :: tensorflow::Input params, :: tensorflow::Input indices) |
Atrybuty publiczne | |
---|---|
operation | |
output |
Funkcje publiczne | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
Atrybuty publiczne
operacja
Operation operation
wynik
::tensorflow::Output output
Funkcje publiczne
GatherNd
GatherNd( const ::tensorflow::Scope & scope, ::tensorflow::Input params, ::tensorflow::Input indices )
węzeł
::tensorflow::Node * node() const
operator :: tensorflow :: Input
operator::tensorflow::Input() const
operator :: tensorflow :: Output
operator::tensorflow::Output() const