tensor akışı:: işlem:: ToplaNd
#include <array_ops.h> params dilimleri, indices belirtilen şekle sahip bir Tensörde toplayın .
Özet
indices K boyutlu bir tamsayı tensörüdür; en iyi şekilde indekslerin params dönüştürüldüğü (K-1) boyutlu bir tensör olarak düşünülebilir; burada her öğe bir params dilimini tanımlar:
output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]] tf.gather indices params ilk boyutundaki dilimleri tanımlarken, tf.gather_nd indices params ilk N boyutundaki dilimleri tanımlar; burada N = indices.shape[-1] .
indices son boyutu en fazla params sıralaması olabilir:
indices.shape[-1] <= params.rank
indices son boyutu, params indices.shape[-1] indices.shape[-1] == params.rank ) veya dilimlere (if indices.shape[-1] < params.rank ) karşılık gelir . Çıkış tensörünün şekli vardır
indices.shape[:-1] + params.shape[indices.shape[-1]:]
CPU'da sınır dışı bir dizin bulunursa bir hata döndürüleceğini unutmayın. GPU'da, sınırların dışında bir dizin bulunursa karşılık gelen çıkış değerinde 0 saklanır.
Aşağıda bazı örnekler.
Bir matrise basit indeksleme:
indices = [[0, 0], [1, 1]]
params = [['a', 'b'], ['c', 'd']]
output = ['a', 'd']İndekslemeyi bir matrise dilimleyin:
indices = [[1], [0]]
params = [['a', 'b'], ['c', 'd']]
output = [['c', 'd'], ['a', 'b']]3 tensöre indeksleme:
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']Bir matrise toplu indeksleme:
indices = [[[0, 0]], [[0, 1]]]
params = [['a', 'b'], ['c', 'd']]
output = [['a'], ['b']]Bir matrise toplu dilim indeksleme:
indices = [[[1]], [[0]]]
params = [['a', 'b'], ['c', 'd']]
output = [[['c', 'd']], [['a', 'b']]]3 tensöre toplu indeksleme:
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']] Ayrıca bkz tf.gather ve tf.batch_gather .
Argümanlar:
- kapsam: Bir Kapsam nesnesi
- params: Değerlerin toplanacağı tensör.
- endeksler: Endeks tensörü.
İade:
-
Output:indicestarafından verilen indekslerden, şekilindices.shape[:-1] + params.shape[indices.shape[-1]:]ile toplananparamselde edilen değerler.
Yapıcılar ve Yıkıcılar | |
|---|---|
GatherNd (const :: tensorflow::Scope & scope, :: tensorflow::Input params, :: tensorflow::Input indices) |
Genel özellikler | |
|---|---|
operation | |
output | |
Kamu işlevleri | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
Genel özellikler
operasyon
Operation operation
çıktı
::tensorflow::Output output
Kamu işlevleri
ToplaNd
GatherNd( const ::tensorflow::Scope & scope, ::tensorflow::Input params, ::tensorflow::Input indices )
düğüm
::tensorflow::Node * node() const
operatör::tensorflow::Giriş
operator::tensorflow::Input() const
operatör::tensorflow::Çıktı
operator::tensorflow::Output() const