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 מגדיר פרוסות לתוך ממד 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 . לטנזור הפלט יש צורה
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, עם shapeindices.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
תפקידים ציבוריים
אסף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
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2026-11-05 (שעון UTC).