Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
dòng chảy căng:: ôi:: DiagPart
#include <array_ops.h>
Trả về phần đường chéo của tensor.
Bản tóm tắt
Hoạt động này trả về một tensor có phần diagonal
của input
. Phần diagonal
được tính như sau:
Giả sử input
có kích thước [D1,..., Dk, D1,..., Dk]
, thì đầu ra là một tenxơ hạng k
có kích thước [D1,..., Dk]
trong đó:
diagonal[i1,..., ik] = input[i1, ..., ik, i1,..., ik]
.
Ví dụ:
# 'input' is [[1, 0, 0, 0]
[0, 2, 0, 0]
[0, 0, 3, 0]
[0, 0, 0, 4]]
tf.diag_part(input) ==> [1, 2, 3, 4]
Lập luận:
- phạm vi: Một đối tượng Phạm vi
- đầu vào: Xếp hạng k tenxơ trong đó k chẵn và khác 0.
Trả về:
-
Output
: Đường chéo được trích xuất.
Thuộc tính công khai
Chức năng công cộng
nút
::tensorflow::Node * node() const
operator::tensorflow::Input() const
toán tử::tenorflow::Đầu ra
operator::tensorflow::Output() const
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[],[],null,["# tensorflow::ops::DiagPart Class Reference\n\ntensorflow::ops::DiagPart\n=========================\n\n`#include \u003carray_ops.h\u003e`\n\nReturns the diagonal part of the tensor.\n\nSummary\n-------\n\nThis operation returns a tensor with the `diagonal` part of the `input`. The `diagonal` part is computed as follows:\n\nAssume `input` has dimensions `[D1,..., Dk, D1,..., Dk]`, then the output is a tensor of rank `k` with dimensions `[D1,..., Dk]` where:\n\n`diagonal[i1,..., ik] = input[i1, ..., ik, i1,..., ik]`.\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```\n\n\u003cbr /\u003e\n\n\n```scdoc\ntf.diag_part(input) ==\u003e [1, 2, 3, 4]\n```\n\n\u003cbr /\u003e\n\nArguments:\n\n- scope: A [Scope](/versions/r2.1/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- input: Rank k tensor where k is even and not zero.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): The extracted diagonal.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [DiagPart](#classtensorflow_1_1ops_1_1_diag_part_1a722e0fbf9139d42128d88361fcceffbb)`(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)` input)` ||\n\n| ### Public attributes ||\n|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [diagonal](#classtensorflow_1_1ops_1_1_diag_part_1a5c2700969d74c5dcd441f482f69f0575) | `::`[tensorflow::Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [operation](#classtensorflow_1_1ops_1_1_diag_part_1a4a4d8b4387110108a77726a4e37f75ef) | [Operation](/versions/r2.1/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n\n| ### Public functions ||\n|---------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_diag_part_1a7f5dfaa792daf4eebe39b740aaa5a117)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_diag_part_1aef16d4b10102516c099741c0935952e9)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_diag_part_1a3ffd8291e65d1b66c89fbcc0bb34225e)`() 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### DiagPart\n\n```gdscript\n DiagPart(\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```"]]