จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เทนเซอร์โฟลว์:: ปฏิบัติการ:: TensorArrayGrad
#include <data_flow_ops.h>
สร้าง TensorArray สำหรับจัดเก็บการไล่ระดับสีของค่าในแฮนเดิลที่กำหนด
สรุป
หากมีการไล่ระดับสี TensorArray ที่กำหนดอยู่แล้ว ให้ส่งคืนการอ้างอิงไปยังการไล่ระดับสีนั้น
ล็อกขนาดของ TensorArray ดั้งเดิมโดยปิดใช้การตั้งค่าสถานะขนาดไดนามิก
หมายเหตุเกี่ยวกับอินพุต flow_in:
หมายเลขอ้างอิง flow_in บังคับให้การดำเนินการค้นหาการไล่ระดับสีเกิดขึ้นหลังจากการดำเนินการอื่นบางอย่างเกิดขึ้นเท่านั้น ตัวอย่างเช่น เมื่อ Forward TensorArray มีขนาดแบบไดนามิก การเขียนไปยัง TensorArray นี้อาจปรับขนาดวัตถุ การไล่ระดับสี TensorArray มีขนาดคงที่โดยอิงตามขนาดของ TensorArray ข้างหน้าเมื่อการดำเนินการนี้ดำเนินการ นอกจากนี้ ขนาดของ TensorArray ที่ส่งต่อจะถูกหยุดโดยการเรียกนี้ ด้วยเหตุนี้ โฟลว์จึงถูกใช้เพื่อให้แน่ใจว่าการเรียกเพื่อสร้างการไล่ระดับสี TensorArray จะเกิดขึ้นหลังจากดำเนินการเขียนทั้งหมดแล้วเท่านั้น
ในกรณีของ TensorArrays ที่มีขนาดไดนามิก การคำนวณการไล่ระดับสีควรทำเฉพาะกับการดำเนินการอ่านที่เชื่อมโยงกันผ่านโฟลว์เท่านั้น ซึ่งจะเกิดขึ้นหลังจากดำเนินการเขียนทั้งหมดแล้วเท่านั้น วิธีนี้จะทำให้ทราบขนาดสุดท้ายของ TensorArray ข้างหน้าเมื่อมีการเรียกการดำเนินการนี้
หมายเหตุเกี่ยวกับแอตทริบิวต์แหล่งที่มา:
การเรียกการไล่ระดับ TensorArray ใช้วัตถุ TensorArray แบบสะสม หากมีการคำนวณและเรียกใช้การไล่ระดับสีหลายรายการในเซสชันเดียวกัน โหนดการไล่ระดับสีหลายรายการอาจไหลผ่านตัวสะสม TensorArray เดียวกันโดยไม่ตั้งใจ การนับสองครั้งนี้และโดยทั่วไปจะทำลายโฟลว์การไล่ระดับสี ของ TensorArray
วิธีแก้ไขคือการระบุว่าการไล่ระดับสีใดที่เรียกการไล่ระดับสี TensorArray นี้โดยเฉพาะ ซึ่งดำเนินการโดยการระบุสตริงที่ไม่ซ้ำกัน (เช่น "gradients", "gradients_1", ... ) จากชื่อของ Tensor การไล่ระดับสีอินพุต สตริงนี้ใช้เป็นคำต่อท้ายเมื่อสร้างวัตถุไล่ระดับสี TensorArray ที่นี่ ( source
ของแอตทริบิวต์)
source
ของแอตทริบิวต์จะถูกเพิ่มเป็นส่วนต่อท้ายชื่อของ TensorArray ข้างหน้าเมื่อดำเนินการสร้าง/ค้นหา เพื่อให้การคำนวณการไล่ระดับสีแยกกันแต่ละรายการได้รับตัวสะสม TensorArray ของตัวเอง
ข้อโต้แย้ง:
- ขอบเขต: วัตถุ ขอบเขต
- ที่จับ: ที่จับสำหรับ TensorArray ไปข้างหน้า
- flow_in: สเกลาร์โฟลตที่บังคับใช้การเชื่อมโยงการดำเนินการที่เหมาะสม
- แหล่งที่มา: สตริงแหล่งที่มาของการไล่ระดับสี ใช้ในการตัดสินใจว่า TensorArray ไล่ ระดับสีใดที่จะส่งคืน
ผลตอบแทน:
คุณลักษณะสาธารณะ
งานสาธารณะ
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[],[],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```"]]