tensorflow:: אופס:: GatherNd
#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
מגדירים פרוסות לממד הראשון של 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
. לטנזור הפלט יש צורה
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']]]
אינדקס אצווה לתוך 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
.
טיעונים:
- scope: אובייקט Scope
- params: הטנזור שממנו לאסוף ערכים.
- מדדים: טנסור אינדקס.
החזרות:
-
Output
: ערכיםparams
שנאספו ממדדים שניתנו על ידיindices
, עם shapeindices.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
תפקידים ציבוריים
GatherNd
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