تدفق التوتر:: العمليات:: تحديث
#include <state_ops.h>
يطبق updates
متفرقة على القيم الفردية أو الشرائح ضمن نطاق محدد.
ملخص
متغير حسب indices
.
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 عناصر. في بايثون، سيبدو هذا التحديث كما يلي:
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])
update = tf.scatter_nd_update(ref, indices, updates)
with tf.Session() as sess:
print sess.run(update)
سيبدو التحديث الناتج إلى المرجع كما يلي:
[1, 11, 3, 10, 9, 6, 7, 12]
راجع tf.scatter_nd
للحصول على مزيد من التفاصيل حول كيفية إجراء تحديثات على الشرائح.
راجع أيضًا tf.scatter_update
و tf.batch_scatter_update
.
الحجج:
- النطاق: كائن النطاق
- المرجع: موتر قابل للتغيير. يجب أن يكون من عقدة متغيرة .
- المؤشرات: موتر . يجب أن يكون أحد الأنواع التالية: int32، int64. موتر من المؤشرات في المرجع.
- التحديثات: موتر . يجب أن يكون له نفس النوع مثل المرجع. موتر القيم المحدثة لإضافتها إلى المرجع.
السمات الاختيارية (انظر Attrs
):
- use_locking: منطقي اختياري. الافتراضيات إلى صحيح. إذا كان True، فسيتم حماية المهمة بواسطة قفل؛ وإلا فإن السلوك غير محدد، ولكنه قد يحمل قدرًا أقل من الخلاف.
العوائد:
-
Output
: نفس المرجع. يتم إرجاعها لتسهيل العمليات التي تريد استخدام القيم المحدثة بعد الانتهاء من التحديث.
الصفات العامة
عملية
Operation operation
input_ref
::tensorflow::Output output_ref
الوظائف العامة
تحديث
ScatterNdUpdate(
const ::tensorflow::Scope & scope,
::tensorflow::Input ref,
::tensorflow::Input indices,
::tensorflow::Input updates
)
تحديث
ScatterNdUpdate(
const ::tensorflow::Scope & scope,
::tensorflow::Input ref,
::tensorflow::Input indices,
::tensorflow::Input updates,
const ScatterNdUpdate::Attrs & attrs
)
العقدة
::tensorflow::Node * node() const
operator::tensorflow::Input() const
المشغل::tensorflow::الإخراج
operator::tensorflow::Output() const
وظائف ثابتة العامة
UseLocking
Attrs UseLocking(
bool x
)
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# tensorflow::ops::ScatterNdUpdate Class Reference\n\ntensorflow::ops::ScatterNdUpdate\n================================\n\n`#include \u003cstate_ops.h\u003e`\n\nApplies sparse `updates` to individual values or slices within a given.\n\nSummary\n-------\n\nvariable according to `indices`.\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$$\\[d_0, ..., d_{Q-2}, ref.shape\\[K\\], ..., ref.shape\\[P-1\\]\\].$$\n\nFor example, say we want to update 4 scattered elements to a rank-1 tensor to 8 elements. In Python, that update would look like this:\n\n\n```gdscript\n ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8])\n indices = tf.constant([[4], [3], [1] ,[7]])\n updates = tf.constant([9, 10, 11, 12])\n update = tf.scatter_nd_update(ref, indices, updates)\n with tf.Session() as sess:\n print sess.run(update)\n```\n\n\u003cbr /\u003e\n\nThe resulting update to ref would look like this: \n\n```text\n[1, 11, 3, 10, 9, 6, 7, 12]\n```\n\n\u003cbr /\u003e\n\nSee `tf.scatter_nd` for more details about how to make updates to slices.\n\nSee also `tf.scatter_update` and `tf.batch_scatter_update`.\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-update/attrs#structtensorflow_1_1ops_1_1_scatter_nd_update_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| [ScatterNdUpdate](#classtensorflow_1_1ops_1_1_scatter_nd_update_1acb6b3b44045199decc158f661ed16c3f)`(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| [ScatterNdUpdate](#classtensorflow_1_1ops_1_1_scatter_nd_update_1ae3aa0b51b9e1787da8db1bf0b0eff7a2)`(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 `[ScatterNdUpdate::Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/scatter-nd-update/attrs#structtensorflow_1_1ops_1_1_scatter_nd_update_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_scatter_nd_update_1a8d113d05ce297b3fbdfe5ec0108a9d2a) | [Operation](/versions/r1.15/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output_ref](#classtensorflow_1_1ops_1_1_scatter_nd_update_1a3207186292f8bca8cf869bc6a6aa2f82) | `::`[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_update_1aa755e0d558f6d9154ad504413b815c87)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_scatter_nd_update_1aaf1431785e8afb4ad1f0498144a12e6b)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_scatter_nd_update_1a2e39eab6b05cd85493c30752a36ca1ea)`() const ` | ` ` ` ` |\n\n| ### Public static functions ||\n|----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|\n| [UseLocking](#classtensorflow_1_1ops_1_1_scatter_nd_update_1aecb251dcdebad69c21d53f5980d0dd80)`(bool x)` | [Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/scatter-nd-update/attrs#structtensorflow_1_1ops_1_1_scatter_nd_update_1_1_attrs) |\n\n| ### Structs ||\n|----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::ScatterNdUpdate::Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/scatter-nd-update/attrs) | Optional attribute setters for [ScatterNdUpdate](/versions/r1.15/api_docs/cc/class/tensorflow/ops/scatter-nd-update#classtensorflow_1_1ops_1_1_scatter_nd_update). |\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### ScatterNdUpdate\n\n```gdscript\n ScatterNdUpdate(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input ref,\n ::tensorflow::Input indices,\n ::tensorflow::Input updates\n)\n``` \n\n### ScatterNdUpdate\n\n```gdscript\n ScatterNdUpdate(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input ref,\n ::tensorflow::Input indices,\n ::tensorflow::Input updates,\n const ScatterNdUpdate::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```"]]