टेंसरफ़्लो:: ऑप्स:: इकट्ठा करो

#include <array_ops.h>

indices द्वारा निर्दिष्ट आकार के साथ params से स्लाइस को एक टेंसर में इकट्ठा करें

सारांश

indices एक K-आयामी पूर्णांक टेंसर है, जिसे params में सूचकांकों के (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] == params.rank ) या स्लाइस (यदि indices.shape[-1] < params.rank ) आयाम indices.shape[-1] params के साथ . आउटपुट टेंसर का आकार

indices.shape[:-1] + params.shape[indices.shape[-1]:]
है

ध्यान दें कि सीपीयू पर, यदि कोई आउट ऑफ बाउंड इंडेक्स पाया जाता है, तो एक त्रुटि वापस आ जाती है। जीपीयू पर, यदि आउट ऑफ बाउंड इंडेक्स पाया जाता है, तो संबंधित आउटपुट मान में 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']]]

3-टेंसर में बैच अनुक्रमण:

    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 भी देखें।

तर्क:

  • स्कोप: एक स्कोप ऑब्जेक्ट
  • पैरामीटर: वह टेंसर जिससे मान एकत्रित करना है।
  • सूचकांक: सूचकांक टेंसर।

रिटर्न:

  • 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