تدفق التوتر:: العمليات:: TensorArrayGrad
#include <data_flow_ops.h>
ينشئ TensorArray لتخزين تدرجات القيم في المقبض المحدد.
ملخص
إذا كان تدرج TensorArray المحدد موجودًا بالفعل، فسيتم إرجاع مرجع إليه.
يقفل حجم TensorArray الأصلي عن طريق تعطيل علامة الحجم الديناميكي الخاصة به.
ملاحظة حول تدفق الإدخال:
يفرض المقبضflow_in تنفيذ بحث التدرج ليتم تنفيذه فقط بعد حدوث عمليات أخرى معينة. على سبيل المثال، عندما يتم تغيير حجم TensorArray الأمامي ديناميكيًا، قد تؤدي الكتابة إلى TensorArray إلى تغيير حجم الكائن. يتم تحديد حجم التدرج TensorArray بشكل ثابت بناءً على حجم TensorArray الأمامي عند تنفيذ هذه العملية. علاوة على ذلك، يتم تجميد حجم TensorArray الأمامي بواسطة هذا الاستدعاء. ونتيجة لذلك، يتم استخدام التدفق للتأكد من أن استدعاء إنشاء TensorArray التدرج يحدث فقط بعد تنفيذ جميع عمليات الكتابة.
في حالة TensorArrays ذات الحجم الديناميكي، يجب إجراء حساب التدرج فقط على عمليات القراءة التي تم ربطها بنفسها عبر التدفق لتحدث فقط بعد تنفيذ جميع عمليات الكتابة. بهذه الطريقة يتم معرفة الحجم النهائي لـ TensorArray الأمامي عند استدعاء هذه العملية.
ملاحظة حول سمة المصدر:
تستخدم مكالمات التدرج TensorArray كائن TensorArray المتراكم. إذا تم حساب تدرجات متعددة وتشغيلها في نفس الجلسة، فقد تتدفق عقد التدرج المتعددة عن طريق الخطأ عبر نفس المجمع TensorArray . يعد هذا أمرًا مزدوجًا ويكسر بشكل عام تدفق التدرج TensorArray .
الحل هو تحديد استدعاء التدرج الذي يتم استدعاء تدرج TensorArray المحدد فيه. ويتم تنفيذ ذلك عن طريق تحديد سلسلة فريدة (على سبيل المثال، "التدرجات"، "gradients_1"، ...) من اسم Tensor لتدرج الإدخال. يتم استخدام هذه السلسلة كلاحقة عند إنشاء كائن التدرج TensorArray هنا ( source
السمة).
تتم إضافة source
السمة كلاحقة لاسم TensorArray الأمامي عند إجراء الإنشاء/البحث، بحيث تحصل كل عملية حسابية منفصلة للتدرج على مجمع TensorArray الخاص بها.
الحجج:
- النطاق: كائن النطاق
- المقبض: المقبض إلى الأمام TensorArray .
- flow_in: عددي عائم يفرض التسلسل الصحيح للعمليات.
- المصدر: سلسلة مصدر التدرج، المستخدمة لتحديد التدرج الذي سيتم إرجاعه من قبل TensorArray .
العوائد:
الصفات العامة
flow_out
::tensorflow::Output flow_out
grad_handle
::tensorflow::Output grad_handle
عملية
Operation operation
الوظائف العامة
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# tensorflow::ops::TensorArrayGrad Class Reference\n\ntensorflow::ops::TensorArrayGrad\n================================\n\n`#include \u003cdata_flow_ops.h\u003e`\n\nCreates a [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) for storing the gradients of values in the given handle.\n\nSummary\n-------\n\nIf the given [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) gradient already exists, returns a reference to it.\n\nLocks the size of the original [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) by disabling its dynamic size flag.\n\n\n**A note about the input flow_in:**\n\nThe handle flow_in forces the execution of the gradient lookup to occur only after certain other operations have occurred. For example, when the forward [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) is dynamically sized, writes to this [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) may resize the object. The gradient [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) is statically sized based on the size of the forward [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) when this operation executes. Furthermore, the size of the forward [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) is frozen by this call. As a result, the flow is used to ensure that the call to generate the gradient [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) only happens after all writes are executed.\n\nIn the case of dynamically sized TensorArrays, gradient computation should only be performed on read operations that have themselves been chained via flow to occur only after all writes have executed. That way the final size of the forward [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) is known when this operation is called.\n\n\n**A note about the source attribute:**\n\n[TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) gradient calls use an accumulator [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) object. If multiple gradients are calculated and run in the same session, the multiple gradient nodes may accidentally flow through the same accumulator [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array). This double counts and generally breaks the [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) gradient flow.\n\nThe solution is to identify which gradient call this particular [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) gradient is being called in. This is performed by identifying a unique string (e.g. \"gradients\", \"gradients_1\", ...) from the input gradient [Tensor](/versions/r2.1/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor)'s name. This string is used as a suffix when creating the [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) gradient object here (the attribute `source`).\n\nThe attribute `source` is added as a suffix to the forward [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array)'s name when performing the creation / lookup, so that each separate gradient calculation gets its own [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) accumulator.\n\nArguments:\n\n- scope: A [Scope](/versions/r2.1/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- handle: The handle to the forward [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array).\n- flow_in: A float scalar that enforces proper chaining of operations.\n- source: The gradient source string, used to decide which gradient [TensorArray](/versions/r2.1/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) to return.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) grad_handle\n- [Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) flow_out\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [TensorArrayGrad](#classtensorflow_1_1ops_1_1_tensor_array_grad_1a6240f50f9c7efdcf3bf8d48c4218d27b)`(const ::`[tensorflow::Scope](/versions/r2.1/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.1/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` handle, ::`[tensorflow::Input](/versions/r2.1/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` flow_in, StringPiece source)` ||\n\n| ### Public attributes ||\n|-------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [flow_out](#classtensorflow_1_1ops_1_1_tensor_array_grad_1a2499ef8bb9c633df24389a51f37654da) | `::`[tensorflow::Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [grad_handle](#classtensorflow_1_1ops_1_1_tensor_array_grad_1ab5be040d777eb52f767d58a83a3a345d) | `::`[tensorflow::Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [operation](#classtensorflow_1_1ops_1_1_tensor_array_grad_1ae7c0b0022fc4a44d321bf759c55413c2) | [Operation](/versions/r2.1/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n\nPublic attributes\n-----------------\n\n### flow_out\n\n```scdoc\n::tensorflow::Output flow_out\n``` \n\n### grad_handle\n\n```scdoc\n::tensorflow::Output grad_handle\n``` \n\n### operation\n\n```text\nOperation operation\n``` \n\nPublic functions\n----------------\n\n### TensorArrayGrad\n\n```gdscript\n TensorArrayGrad(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input handle,\n ::tensorflow::Input flow_in,\n StringPiece source\n)\n```"]]