tensorflow::ops::GatherNd
#include <array_ops.h> params , indices belirtilen şekle sahip bir Tensor'a dilimler toplayın .
Özet
indices , K boyutlu bir tamsayı tensörüdür ve en iyi şekilde params ait indekslerin (K-1) boyutlu bir tensörü olarak düşünülebilir; burada her eleman params bir dilimini tanımlar:
output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]] tf.gather indices params ilk boyutuna dilimler tanımlarken, tf.gather_nd indices , params ilk N boyutuna dilimler 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] == params.rank ) veya dilimlere (eğer indices.shape[ indices.shape[-1] indices.shape[-1] < params.rank ise) karşılık gelir. Çıktı tensörünün şekli şöyledir:
indices.shape[:-1] + params.shape[indices.shape[-1]:]
CPU'da, dizin sınırlarının dışında bir değer bulunursa hata döndürülür. GPU'da ise, dizin sınırlarının dışında bir değer bulunursa, ilgili çıktı değerine 0 değeri kaydedilir.
Aşağıda bazı örnekler verilmiştir.
Matrise basit indeksleme:
indices = [[0, 0], [1, 1]]
params = [['a', 'b'], ['c', 'd']]
output = ['a', 'd']Matrise dilimleme indeksleme:
indices = [[1], [0]]
params = [['a', 'b'], ['c', 'd']]
output = [['c', 'd'], ['a', 'b']]3 boyutlu bir 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']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 boyutlu bir 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 tf.gather ve tf.batch_gather fonksiyonlarına da bakınız.
Argümanlar:
- kapsam: Bir Kapsam nesnesi
- params: Değerlerin toplanacağı tensör.
- İndeksler: İndeks tensörü.
İadeler:
-
Output:indicestarafından verilen indekslerden toplananparamsdeğerleri,indices.shape[:-1] + params.shape[indices.shape[-1]:]şeklindedir.
Yapıcılar ve Yıkıcılar | |
|---|---|
GatherNd (const :: tensorflow::Scope & scope, :: tensorflow::Input params, :: tensorflow::Input indices) |
Genel özellikler | |
|---|---|
operation | |
output | |
Kamusal işlevler | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
Genel özellikler
operasyon
Operation operation
çıktı
::tensorflow::Output output
Kamusal işlevler
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