تدفق التوتر:: العمليات:: جمع Nd
#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}\\)]]
بينما تحدد indices
في tf.gather
الشرائح في بُعد axis
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']]
الفهرسة في موتر 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) |
الوظائف العامة | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
الصفات العامة
عملية
Operation operation
الإخراج
::tensorflow::Output output
الوظائف العامة
جمع Nd
GatherNd(
const ::tensorflow::Scope & scope,
::tensorflow::Input params,
::tensorflow::Input indices
)
العقدة
::tensorflow::Node * node() const
المشغل::tensorflow::الإدخال
operator::tensorflow::Input() const
المشغل::tensorflow::الإخراج
operator::tensorflow::Output() const