tensorflow :: ops :: GatherNd
#include <array_ops.h>
Kumpulkan potongan dari params
ke dalam Tensor dengan bentuk yang ditentukan oleh indices
.
Ringkasan
indices
adalah tensor bilangan bulat berdimensi K, yang paling baik dianggap sebagai tensor berdimensi (K-1) dari indeks ke dalam params
, di mana setiap elemen mendefinisikan sepotong params
:
output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]]
Sedangkan di tf.gather
indices
mendefinisikan irisan ke dalam axis
dimensi params
, di tf.gather_nd
, indices
mendefinisikan iris menjadi yang pertama N
dimensi params
, di mana N = indices.shape[-1]
.
Dimensi indices
terakhir paling banyak dapat peringkat params
:
indices.shape[-1] <= params.rank
Dimensi terakhir dari indices
sesuai dengan elemen (if indices.shape[-1] == params.rank
) atau slices (if indices.shape[-1] < params.rank
) sepanjang indices.shape[-1] < params.rank
dimensi.shape indices.shape[-1]
dari params
. Tensor keluaran berbentuk
indices.shape[:-1] + params.shape[indices.shape[-1]:]
Perhatikan bahwa pada CPU, jika indeks di luar batas ditemukan, kesalahan dikembalikan. Di GPU, jika indeks di luar batas ditemukan, 0 disimpan dalam nilai keluaran yang sesuai.
Beberapa contoh di bawah ini.
Pengindeksan sederhana ke dalam matriks:
indices = [[0, 0], [1, 1]] params = [['a', 'b'], ['c', 'd']] output = ['a', 'd']
Iris pengindeksan menjadi matriks:
indices = [[1], [0]] params = [['a', 'b'], ['c', 'd']] output = [['c', 'd'], ['a', 'b']]
Mengindeks menjadi 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']
Pengindeksan berkelompok menjadi matriks:
indices = [[[0, 0]], [[0, 1]]] params = [['a', 'b'], ['c', 'd']] output = [['a'], ['b']]
Pengindeksan irisan bertumpuk menjadi matriks:
indices = [[[1]], [[0]]] params = [['a', 'b'], ['c', 'd']] output = [[['c', 'd']], [['a', 'b']]]
Pengindeksan bertumpuk menjadi 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']]
Lihat juga tf.gather
dan tf.batch_gather
.
Argumen:
- scope: Objek Scope
- params: Tensor tempat mengumpulkan nilai.
- indeks: Tensor indeks.
Pengembalian:
-
Output
: Nilai dariparams
dikumpulkan dari indeks yang diberikan olehindices
, denganindices
indices.shape[:-1] + params.shape[indices.shape[-1]:]
.
Pembuat dan Penghancur | |
---|---|
GatherNd (const :: tensorflow::Scope & scope, :: tensorflow::Input params, :: tensorflow::Input indices) |
Atribut publik | |
---|---|
operation | |
output |
Fungsi publik | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
Atribut publik
operasi
Operation operation
keluaran
::tensorflow::Output output
Fungsi publik
GatherNd
GatherNd( const ::tensorflow::Scope & scope, ::tensorflow::Input params, ::tensorflow::Input indices )
simpul
::tensorflow::Node * node() const
operator :: tensorflow :: Input
operator::tensorflow::Input() const
operator :: tensorflow :: Keluaran
operator::tensorflow::Output() const