tensorflow:: ops:: GatherNd

#include <array_ops.h>

قم بتجميع الشرائح من params في موتر ذي شكل محدد بواسطة indices .

ملخص

indices عبارة عن موتر عدد صحيح ذو K بُعد، ويمكن اعتباره على أفضل وجه موترًا ذا (K-1) بُعد من الفهارس في params ، حيث يحدد كل عنصر شريحة من params :

output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]]

بينما في tf.gather indices يحدد الشرائح في البعد الأول من params ، في tf.gather_nd ، يحدد indices الشرائح في أول N أبعاد من params ، حيث 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']]

الفهرسة في موتر ثلاثي الأبعاد:

    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 .

الحجج:

  • النطاق: كائن النطاق
  • المعاملات: الموتر الذي يتم من خلاله جمع القيم.
  • المؤشرات: موتر المؤشر.

المرتجعات:

  • Output : القيم من params المجمعة من الفهارس المعطاة بواسطة indices ، مع شكل 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

 operator::tensorflow::Input() const 

operator::tensorflow::Output

 operator::tensorflow::Output() const