จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เทนเซอร์โฟลว์:: ปฏิบัติการ:: กระจายNdSub
#include <state_ops.h>
ใช้การลบแบบกระจายกับแต่ละค่าหรือส่วนย่อยใน ตัวแปร
สรุป
ภายในตัวแปรที่กำหนดตาม 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 องค์ประกอบ ใน 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])
sub = tf.scatter_nd_sub(ref, indices, updates)
with tf.Session() as sess:
print sess.run(sub)
ผลลัพธ์การอัปเดตเพื่ออ้างอิงจะมีลักษณะดังนี้:
[1, -9, 3, -6, -4, 6, 7, -4]
ดู tf.scatter_nd
สำหรับรายละเอียดเพิ่มเติมเกี่ยวกับวิธีการอัปเดตสไลซ์
ข้อโต้แย้ง:
- ขอบเขต: วัตถุ ขอบเขต
- ref: เทนเซอร์ ที่ไม่แน่นอน ควรมาจากโหนด ตัวแปร
- ดัชนี: เทนเซอร์ ต้องเป็นประเภทใดประเภทหนึ่งต่อไปนี้: int32, int64 เทนเซอร์ของดัชนีในการอ้างอิง
- อัปเดต: เทนเซอร์ จะต้องมีประเภทเดียวกันกับการอ้างอิง เทนเซอร์ของค่าที่อัพเดตเพื่อลบออกจากการอ้างอิง
แอ็ตทริบิวต์ทางเลือก (ดู Attrs
):
- use_locking: บูลเสริม ค่าเริ่มต้นเป็น True ถ้าเป็น True งานที่ได้รับมอบหมายจะได้รับการปกป้องด้วยการล็อค มิฉะนั้นพฤติกรรมจะไม่ได้กำหนดไว้ แต่อาจแสดงความขัดแย้งน้อยลง
ผลตอบแทน:
-
Output
: เช่นเดียวกับการอ้างอิง กลับมาเพื่อความสะดวกสำหรับการดำเนินงานที่ต้องการใช้ค่าที่อัพเดตหลังจากการอัพเดตเสร็จสิ้น
คุณลักษณะสาธารณะ
งานสาธารณะ
โหนด
::tensorflow::Node * node() const
operator::tensorflow::Input() const
ตัวดำเนินการ::tensorflow::เอาต์พุต
operator::tensorflow::Output() const
ฟังก์ชันคงที่สาธารณะ
ใช้ล็อค
Attrs UseLocking(
bool x
)
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[null,null,["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# tensorflow::ops::ScatterNdSub Class Reference\n\ntensorflow::ops::ScatterNdSub\n=============================\n\n`#include \u003cstate_ops.h\u003e`\n\nApplies sparse subtraction to individual values or slices in a [Variable](/versions/r2.2/api_docs/cc/class/tensorflow/ops/variable#classtensorflow_1_1ops_1_1_variable).\n\nSummary\n-------\n\nwithin a given variable according to `indices`.\n\n`ref` is a [Tensor](/versions/r2.2/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) with rank `P` and `indices` is a [Tensor](/versions/r2.2/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/r2.2/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 subtract 4 scattered elements from a rank-1 tensor with 8 elements. In Python, that subtraction 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])\nsub = tf.scatter_nd_sub(ref, indices, updates)\nwith tf.Session() as sess:\n print sess.run(sub)\n```\n\n\u003cbr /\u003e\n\nThe resulting update to ref would look like this: \n\n```text\n[1, -9, 3, -6, -4, 6, 7, -4]\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/r2.2/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- ref: A mutable [Tensor](/versions/r2.2/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor). Should be from a [Variable](/versions/r2.2/api_docs/cc/class/tensorflow/ops/variable#classtensorflow_1_1ops_1_1_variable) node.\n- indices: A [Tensor](/versions/r2.2/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/r2.2/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor). Must have the same type as ref. A tensor of updated values to subtract from ref.\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r2.2/api_docs/cc/struct/tensorflow/ops/scatter-nd-sub/attrs#structtensorflow_1_1ops_1_1_scatter_nd_sub_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/r2.2/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| [ScatterNdSub](#classtensorflow_1_1ops_1_1_scatter_nd_sub_1ae406028cdb445b008dc38cb063867d92)`(const ::`[tensorflow::Scope](/versions/r2.2/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` ref, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` updates)` ||\n| [ScatterNdSub](#classtensorflow_1_1ops_1_1_scatter_nd_sub_1a6095e143f12d98bdd6840e3c82b0849e)`(const ::`[tensorflow::Scope](/versions/r2.2/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` ref, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` updates, const `[ScatterNdSub::Attrs](/versions/r2.2/api_docs/cc/struct/tensorflow/ops/scatter-nd-sub/attrs#structtensorflow_1_1ops_1_1_scatter_nd_sub_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_scatter_nd_sub_1a3ce12481ccf50ae215315bae8f9ebaa6) | [Operation](/versions/r2.2/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output_ref](#classtensorflow_1_1ops_1_1_scatter_nd_sub_1a2b35fc093c9c33c9fb2117ce2d348f1e) | `::`[tensorflow::Output](/versions/r2.2/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public functions ||\n|--------------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_scatter_nd_sub_1a395194967a9288f615ec9e74e220043a)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_scatter_nd_sub_1ad87ae02563483cc2d919170789fbf278)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_scatter_nd_sub_1ae3ae0bc213eec019e7ab8a5fe78171df)`() const ` | ` ` ` ` |\n\n| ### Public static functions ||\n|-------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|\n| [UseLocking](#classtensorflow_1_1ops_1_1_scatter_nd_sub_1a0378357edf53a55d9d8bcd4f18730266)`(bool x)` | [Attrs](/versions/r2.2/api_docs/cc/struct/tensorflow/ops/scatter-nd-sub/attrs#structtensorflow_1_1ops_1_1_scatter_nd_sub_1_1_attrs) |\n\n| ### Structs ||\n|---------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::ScatterNdSub::Attrs](/versions/r2.2/api_docs/cc/struct/tensorflow/ops/scatter-nd-sub/attrs) | Optional attribute setters for [ScatterNdSub](/versions/r2.2/api_docs/cc/class/tensorflow/ops/scatter-nd-sub#classtensorflow_1_1ops_1_1_scatter_nd_sub). |\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### ScatterNdSub\n\n```gdscript\n ScatterNdSub(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input ref,\n ::tensorflow::Input indices,\n ::tensorflow::Input updates\n)\n``` \n\n### ScatterNdSub\n\n```gdscript\n ScatterNdSub(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input ref,\n ::tensorflow::Input indices,\n ::tensorflow::Input updates,\n const ScatterNdSub::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```"]]