نشكرك على متابعة Google I / O. عرض جميع الجلسات عند الطلب مشاهدة عند الطلب

تينسورفلو :: العمليات :: تجمع

#include <array_ops.h>

اجمع الشرائح من params إلى Tensor بالشكل المحدد بواسطة indices .

ملخص

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

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

في حين أنه في tf.gather indices يعرف شرائح في axis البعد params ، في tf.gather_nd ، indices يعرف شرائح في أول N أبعاد params ، حيث N = indices.shape[-1] .

البعد الأخير من indices يمكن أن تكون على الأكثر رتبة params :

indices.shape[-1] <= params.rank

يتوافق البعد الأخير indices مع العناصر (if indices.shape[-1] == params.rank ) أو الشرائح (if 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 : القيم من 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 

المشغل :: tensorflow :: الإدخال

 operator::tensorflow::Input() const 

المشغل :: Tensorflow :: Output

 operator::tensorflow::Output() const