टेन्सरफ्लो::ऑप्स::गैदरएनडी
#include <array_ops.h> params से स्लाइस को indices द्वारा निर्दिष्ट आकार वाले टेंसर में एकत्रित करें ।
सारांश
indices एक K-आयामी पूर्णांक टेंसर है, जिसे params में indices के (K-1)-आयामी टेंसर के रूप में सबसे अच्छी तरह समझा जा सकता है, जहां प्रत्येक तत्व params के एक स्लाइस को परिभाषित करता है:
output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]] जबकि tf.gather में indices params के पहले आयाम में स्लाइस को परिभाषित करता है, tf.gather_nd में, indices params के पहले N आयामों में स्लाइस को परिभाषित करता है, जहाँ N = indices.shape[-1] ।
indices का अंतिम आयाम अधिकतम params की रैंक के बराबर हो सकता है:
indices.shape[-1] <= params.rank
indices का अंतिम आयाम, पैरामीटर के indices.shape[-1] indices.shape[-1] == params.rank params या स्लाइस (यदि indices.shape[-1] < params.rank ) से मेल खाता है। आउटपुट टेंसर का आकार होता है।
indices.shape[:-1] + params.shape[indices.shape[-1]:]
ध्यान दें कि CPU पर, यदि कोई इंडेक्स सीमा से बाहर पाया जाता है, तो त्रुटि वापस कर दी जाती है। GPU पर, यदि कोई इंडेक्स सीमा से बाहर पाया जाता है, तो संबंधित आउटपुट मान में 0 संग्रहीत किया जाता है।
नीचे कुछ उदाहरण दिए गए हैं।
मैट्रिक्स में सरल अनुक्रमणिका बनाना:
indices = [[0, 0], [1, 1]]
params = [['a', 'b'], ['c', 'd']]
output = ['a', 'd']मैट्रिक्स में स्लाइस इंडेक्सिंग:
indices = [[1], [0]]
params = [['a', 'b'], ['c', 'd']]
output = [['c', 'd'], ['a', 'b']]3-टेंसर में अनुक्रमणिका बनाना:
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']मैट्रिक्स में बैच इंडेक्सिंग:
indices = [[[0, 0]], [[0, 1]]]
params = [['a', 'b'], ['c', 'd']]
output = [['a'], ['b']]मैट्रिक्स में बैच स्लाइस इंडेक्सिंग:
indices = [[[1]], [[0]]]
params = [['a', 'b'], ['c', 'd']]
output = [[['c', 'd']], [['a', 'b']]]तीन टेंसर में बैच इंडेक्सिंग:
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']] tf.gather और tf.batch_gather भी देखें।
तर्क:
- स्कोप: एक स्कोप ऑब्जेक्ट
- params: वह टेंसर जिससे मान एकत्रित किए जाएंगे।
- सूचकांक: सूचकांक टेंसर।
प्रतिफल:
-
Output:indicesद्वारा दिए गए इंडेक्स से एकत्रितparamsसे मान, आकारindices.shape[:-1] + params.shape[indices.shape[-1]:]के साथ।
कंस्ट्रक्टर और डिस्ट्रक्टर | |
|---|---|
GatherNd (const :: tensorflow::Scope & scope, :: tensorflow::Input params, :: tensorflow::Input indices) |
सार्वजनिक विशेषताएँ | |
|---|---|
operation | |
output | |
सार्वजनिक समारोह | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
सार्वजनिक विशेषताएँ
संचालन
Operation operation
आउटपुट
::tensorflow::Output output
सार्वजनिक समारोह
इकट्ठा करें
GatherNd( const ::tensorflow::Scope & scope, ::tensorflow::Input params, ::tensorflow::Input indices )
नोड
::tensorflow::Node * node() const
ऑपरेटर::टेन्सरफ्लो::इनपुट
operator::tensorflow::Input() const
ऑपरेटर::टेन्सरफ्लो::आउटपुट
operator::tensorflow::Output() const