tensorflow:: אופס:: ScatterNdAdd
#include <state_ops.h>
מחיל תוספת דלילה על ערכים בודדים או פרוסות במשתנה .
תַקצִיר
ref
הוא Tensor
עם דרגה P
indices
הוא Tensor
בדרגה Q
indices
חייבים להיות טנסור שלמים, המכיל מדדים לתוך ref
. זה חייב להיות צורה [d_0, ..., d_{Q-2}, K]
כאשר 0 < K <= P
.
הממד הפנימי ביותר של indices
(עם אורך K
) מתאים למדדים לאלמנטים (אם K = P
) או לפרוסות (אם K < P
) לאורך הממד K
של ref
.
updates
הם Tensor
בדרגה Q-1+PK
עם צורה:
[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]
לדוגמה, נניח שאנו רוצים להוסיף 4 אלמנטים מפוזרים לטנזור בדרגה 1 ל-8 אלמנטים. ב-Python, התוספת הזו תיראה כך:
ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8])
indices = tf.constant([[4], [3], [1], [7]])
updates = tf.constant([9, 10, 11, 12])
add = tf.scatter_nd_add(ref, indices, updates)
with tf.Session() as sess:
print sess.run(add)
העדכון שיתקבל ל-ref ייראה כך:
[1, 13, 3, 14, 14, 6, 7, 20]
ראה tf.scatter_nd
לפרטים נוספים על איך לבצע עדכונים לפרוסות.
טיעונים:
- scope: אובייקט Scope
- ref: Tensor ניתן לשינוי. צריך להיות מצומת משתנה .
- מדדים: A Tensor . חייב להיות אחד מהסוגים הבאים: int32, int64. טנזור של מדדים לתוך ref.
- עדכונים: A Tensor . חייב להיות אותו סוג כמו ref. טנסור של ערכים מעודכנים להוסיף ל-ref.
מאפיינים אופציונליים (ראה Attrs
):
- use_locking: bool אופציונלי. ברירת המחדל ל-True. אם נכון, ההקצאה תהיה מוגנת במנעול; אחרת ההתנהגות אינה מוגדרת, אך עלולה להפגין פחות מחלוקת.
החזרות:
-
Output
: זהה ל-ref. הוחזר כנוחות עבור פעולות שרוצות להשתמש בערכים המעודכנים לאחר ביצוע העדכון.
תכונות ציבוריות
מִבצָע
Operation operation
פלט_ref
::tensorflow::Output output_ref
תפקידים ציבוריים
ScatterNdAdd
ScatterNdAdd(
const ::tensorflow::Scope & scope,
::tensorflow::Input ref,
::tensorflow::Input indices,
::tensorflow::Input updates
)
ScatterNdAdd
ScatterNdAdd(
const ::tensorflow::Scope & scope,
::tensorflow::Input ref,
::tensorflow::Input indices,
::tensorflow::Input updates,
const ScatterNdAdd::Attrs & attrs
)
צוֹמֶת
::tensorflow::Node * node() const
operator::tensorflow::Input() const
אופרטור::tensorflow::פלט
operator::tensorflow::Output() const
פונקציות סטטיות ציבוריות
השתמש בנעילה
Attrs UseLocking(
bool x
)
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-26 (שעון UTC)."],[],[],null,["# tensorflow::ops::ScatterNdAdd Class Reference\n\ntensorflow::ops::ScatterNdAdd\n=============================\n\n`#include \u003cstate_ops.h\u003e`\n\nApplies sparse addition to individual values or slices in a [Variable](/versions/r1.15/api_docs/cc/class/tensorflow/ops/variable#classtensorflow_1_1ops_1_1_variable).\n\nSummary\n-------\n\n`ref` is a [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) with rank `P` and `indices` is a [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) of rank `Q`.\n\n`indices` must be integer tensor, containing indices into `ref`. It must be shape `[d_0, ..., d_{Q-2}, K]` where `0 \u003c K \u003c= P`.\n\nThe innermost dimension of `indices` (with length `K`) corresponds to indices into elements (if `K = P`) or slices (if `K \u003c P`) along the `K`th dimension of `ref`.\n\n`updates` is [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) of rank `Q-1+P-K` with shape:\n\n\n```transact-sql\n[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]\n```\n\n\u003cbr /\u003e\n\nFor example, say we want to add 4 scattered elements to a rank-1 tensor to 8 elements. In Python, that addition would look like this:\n\n\n```gdscript\nref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8])\nindices = tf.constant([[4], [3], [1], [7]])\nupdates = tf.constant([9, 10, 11, 12])\nadd = tf.scatter_nd_add(ref, indices, updates)\nwith tf.Session() as sess:\n print sess.run(add)\n```\n\n\u003cbr /\u003e\n\nThe resulting update to ref would look like this: \n\n```text\n[1, 13, 3, 14, 14, 6, 7, 20]\n```\n\n\u003cbr /\u003e\n\nSee `tf.scatter_nd` for more details about how to make updates to slices.\n\nArguments:\n\n- scope: A [Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- ref: A mutable [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor). Should be from a [Variable](/versions/r1.15/api_docs/cc/class/tensorflow/ops/variable#classtensorflow_1_1ops_1_1_variable) node.\n- indices: A [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor). Must be one of the following types: int32, int64. A tensor of indices into ref.\n- updates: A [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor). Must have the same type as ref. A tensor of updated values to add to ref.\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/scatter-nd-add/attrs#structtensorflow_1_1ops_1_1_scatter_nd_add_1_1_attrs)):\n\n- use_locking: An optional bool. Defaults to True. If True, the assignment will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): Same as ref. Returned as a convenience for operations that want to use the updated values after the update is done.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [ScatterNdAdd](#classtensorflow_1_1ops_1_1_scatter_nd_add_1a138d4ff980f1a1c856fa78bd86a09e54)`(const ::`[tensorflow::Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` ref, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` updates)` ||\n| [ScatterNdAdd](#classtensorflow_1_1ops_1_1_scatter_nd_add_1ae0ef19022b7465666026da0e92b88989)`(const ::`[tensorflow::Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` ref, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` updates, const `[ScatterNdAdd::Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/scatter-nd-add/attrs#structtensorflow_1_1ops_1_1_scatter_nd_add_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_scatter_nd_add_1a1c417c3ef3f4b9045718379caed4fa18) | [Operation](/versions/r1.15/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output_ref](#classtensorflow_1_1ops_1_1_scatter_nd_add_1a87550a24f5b9120902042ec65b457c6a) | `::`[tensorflow::Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public functions ||\n|--------------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_scatter_nd_add_1a2527951beff23f5d906fe8c451a4d3c6)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_scatter_nd_add_1a0f4d17afad4086d274e3a5f342cb6b41)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_scatter_nd_add_1af62e0d7ee1e7c513f1ca2b1e126c6361)`() const ` | ` ` ` ` |\n\n| ### Public static functions ||\n|-------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|\n| [UseLocking](#classtensorflow_1_1ops_1_1_scatter_nd_add_1a6e1404fae24acf1e8128e7f2963fb31c)`(bool x)` | [Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/scatter-nd-add/attrs#structtensorflow_1_1ops_1_1_scatter_nd_add_1_1_attrs) |\n\n| ### Structs ||\n|----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::ScatterNdAdd::Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/scatter-nd-add/attrs) | Optional attribute setters for [ScatterNdAdd](/versions/r1.15/api_docs/cc/class/tensorflow/ops/scatter-nd-add#classtensorflow_1_1ops_1_1_scatter_nd_add). |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### output_ref\n\n```scdoc\n::tensorflow::Output output_ref\n``` \n\nPublic functions\n----------------\n\n### ScatterNdAdd\n\n```gdscript\n ScatterNdAdd(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input ref,\n ::tensorflow::Input indices,\n ::tensorflow::Input updates\n)\n``` \n\n### ScatterNdAdd\n\n```gdscript\n ScatterNdAdd(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input ref,\n ::tensorflow::Input indices,\n ::tensorflow::Input updates,\n const ScatterNdAdd::Attrs & attrs\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n``` \n\nPublic static functions\n-----------------------\n\n### UseLocking\n\n```text\nAttrs UseLocking(\n bool x\n)\n```"]]