จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เทนเซอร์โฟลว์:: ปฏิบัติการ:: MatrixDiagPart
#include <array_ops.h>
ส่งกลับส่วนเส้นทแยงมุมแบบแบทช์ของเทนเซอร์แบบแบทช์
สรุป
การดำเนินการนี้จะส่งคืนเทนเซอร์ที่มีส่วนใน diagonal
ของ input
แบบแบตช์ ส่วน diagonal
คำนวณดังนี้:
สมมติว่า input
มี k
มิติ [I, J, K, ..., M, N]
ดังนั้นเอาต์พุตจะเป็นเทนเซอร์ของอันดับ k - 1
ด้วยขนาด [I, J, K, ..., min(M, N)]
ที่ไหน:
diagonal[i, j, k, ..., n] = input[i, j, k, ..., n, n]
อินพุตต้องมีอย่างน้อยเมทริกซ์
ตัวอย่างเช่น:
# 'input' is [[[1, 0, 0, 0]
[0, 2, 0, 0]
[0, 0, 3, 0]
[0, 0, 0, 4]],
[[5, 0, 0, 0]
[0, 6, 0, 0]
[0, 0, 7, 0]
[0, 0, 0, 8]]]
and input.shape = (2, 4, 4)
tf.matrix_diag_part(input) ==> [[1, 2, 3, 4], [5, 6, 7, 8]]
which has shape (2, 4)
ข้อโต้แย้ง:
- ขอบเขต: วัตถุ ขอบเขต
- อินพุต: อันดับ
k
เทนเซอร์โดยที่ k >= 2
ผลตอบแทน:
-
Output
: เส้นทแยงมุมที่แยกออกมาซึ่งมีรูปร่าง diagonal.shape = input.shape[:-2] + [min(input.shape[-2:])]
คุณลักษณะสาธารณะ
งานสาธารณะ
โหนด
::tensorflow::Node * node() const
operator::tensorflow::Input() const
ตัวดำเนินการ::tensorflow::เอาต์พุต
operator::tensorflow::Output() const
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[],[],null,["# tensorflow::ops::MatrixDiagPart Class Reference\n\ntensorflow::ops::MatrixDiagPart\n===============================\n\n`#include \u003carray_ops.h\u003e`\n\nReturns the batched diagonal part of a batched tensor.\n\nSummary\n-------\n\nThis operation returns a tensor with the `diagonal` part of the batched `input`. The `diagonal` part is computed as follows:\n\nAssume `input` has `k` dimensions `[I, J, K, ..., M, N]`, then the output is a tensor of rank `k - 1` with dimensions `[I, J, K, ..., min(M, N)]` where:\n\n`diagonal[i, j, k, ..., n] = input[i, j, k, ..., n, n]`.\n\nThe input must be at least a matrix.\n\nFor example:\n\n\n```text\n# 'input' is [[[1, 0, 0, 0]\n [0, 2, 0, 0]\n [0, 0, 3, 0]\n [0, 0, 0, 4]],\n [[5, 0, 0, 0]\n [0, 6, 0, 0]\n [0, 0, 7, 0]\n [0, 0, 0, 8]]]\n```\n\n\u003cbr /\u003e\n\n\n```text\nand input.shape = (2, 4, 4)\n```\n\n\u003cbr /\u003e\n\n\n```scdoc\ntf.matrix_diag_part(input) ==\u003e [[1, 2, 3, 4], [5, 6, 7, 8]]\n```\n\n\u003cbr /\u003e\n\n\n```perl6\nwhich has shape (2, 4)\n```\n\n\u003cbr /\u003e\n\nArguments:\n\n- scope: A [Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- input: Rank `k` tensor where `k \u003e= 2`.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): The extracted diagonal(s) having shape `diagonal.shape = input.shape[:-2] + [min(input.shape[-2:])]`.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [MatrixDiagPart](#classtensorflow_1_1ops_1_1_matrix_diag_part_1a2ff08591126639a356e8ddb7b1bbe901)`(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)` input)` ||\n\n| ### Public attributes ||\n|----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [diagonal](#classtensorflow_1_1ops_1_1_matrix_diag_part_1aefc6c0270b1e5a8ecca5253aa3197301) | `::`[tensorflow::Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [operation](#classtensorflow_1_1ops_1_1_matrix_diag_part_1a2ee7a3d61dc294c15227bb4a4fd796fb) | [Operation](/versions/r1.15/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n\n| ### Public functions ||\n|----------------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_matrix_diag_part_1a6310cbc4148604ca613410d6d3f6794e)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_matrix_diag_part_1ab168eaa21921f9a0ff6ca197fbbbd8da)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_matrix_diag_part_1a6ac92f6b3dfd62c3ef3c08777c62d543)`() const ` | ` ` ` ` |\n\nPublic attributes\n-----------------\n\n### diagonal\n\n```text\n::tensorflow::Output diagonal\n``` \n\n### operation\n\n```text\nOperation operation\n``` \n\nPublic functions\n----------------\n\n### MatrixDiagPart\n\n```gdscript\n MatrixDiagPart(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input\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```"]]