संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
टेंसरफ़्लो:: ऑप्स:: मैट्रिक्सडायगपार्टV2
#include <array_ops.h>
बैच किए गए टेंसर का बैच विकर्ण भाग लौटाता है।
सारांश
बैच किए गए input
के k[0]
-वें से k[1]
-वें विकर्णों के साथ एक टेंसर लौटाता है।
मान लें कि input
में r
आयाम हैं [I, J, ..., L, M, N]
। मान लीजिए max_diag_len
निकाले जाने वाले सभी विकर्णों के बीच अधिकतम लंबाई है, max_diag_len = min(M + min(k[1], 0), N + min(-k[0], 0))
मान लीजिए num_diags
विकर्णों की संख्या है निकालें, num_diags = k[1] - k[0] + 1
।
यदि num_diags == 1
, तो आउटपुट टेंसर आकार [I, J, ..., L, max_diag_len]
और मानों के साथ r - 1
रैंक का है:
diagonal[i, j, ..., l, n]
= input[i, j, ..., l, n+y, n+x] ; when 0 <= n-y < M and 0 <= n-x < N,
0 ; otherwise.
जहां
y = max(-k[1], 0)
,
x = max(k[1], 0)
.
अन्यथा, आउटपुट टेंसर में आयामों के साथ रैंक r
है [I, J, ..., L, num_diags, max_diag_len]
मानों के साथ:
diagonal[i, j, ..., l, m, n]
= input[i, j, ..., l, n+y, n+x] ; when 0 <= n-y < M and 0 <= n-x < N,
0 ; otherwise.
जहां
d = k[1] - m
,
y = max(-d, 0)
, और
x = max(d, 0)
.
इनपुट कम से कम एक मैट्रिक्स होना चाहिए.
उदाहरण के लिए:
input = np.array([[[1, 2, 3, 4], # Input shape: (2, 3, 4)
[5, 6, 7, 8],
[9, 8, 7, 6]],
[[5, 4, 3, 2],
[1, 2, 3, 4],
[5, 6, 7, 8]]])
# A main diagonal from each batch.
tf.matrix_diag_part(input) ==> [[1, 6, 7], # Output shape: (2, 3)
[5, 2, 7]]
# A superdiagonal from each batch.
tf.matrix_diag_part(input, k = 1)
==> [[2, 7, 6], # Output shape: (2, 3)
[4, 3, 8]]
# A tridiagonal band from each batch.
tf.matrix_diag_part(input, k = (-1, 1))
==> [[[2, 7, 6], # Output shape: (2, 3, 3)
[1, 6, 7],
[5, 8, 0]],
[[4, 3, 8],
[5, 2, 7],
[1, 6, 0]]]
# Padding = 9
tf.matrix_diag_part(input, k = (1, 3), padding = 9)
==> [[[4, 9, 9], # Output shape: (2, 3, 3)
[3, 8, 9],
[2, 7, 6]],
[[2, 9, 9],
[3, 4, 9],
[4, 3, 8]]]
तर्क:
- स्कोप: एक स्कोप ऑब्जेक्ट
- इनपुट: रैंक
r
टेंसर जहां r >= 2
। - k: विकर्ण ऑफसेट। सकारात्मक मान का अर्थ है सुपरविकर्ण, 0 मुख्य विकर्ण को संदर्भित करता है, और नकारात्मक मान का अर्थ है उपविकर्ण।
k
एक एकल पूर्णांक (एकल विकर्ण के लिए) या मैट्रिक्स बैंड के निम्न और उच्च सिरों को निर्दिष्ट करने वाले पूर्णांकों की एक जोड़ी हो सकता है। k[0]
k[1]
से बड़ा नहीं होना चाहिए। - पैडिंग_वैल्यू: निर्दिष्ट विकर्ण बैंड के बाहर के क्षेत्र को भरने का मान। डिफ़ॉल्ट 0 है.
रिटर्न:
सार्वजनिक गुण
सार्वजनिक समारोह
नोड
::tensorflow::Node * node() const
operator::tensorflow::Input() const
ऑपरेटर::टेन्सरफ़्लो::आउटपुट
operator::tensorflow::Output() const
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया."],[],[],null,["# tensorflow::ops::MatrixDiagPartV2 Class Reference\n\ntensorflow::ops::MatrixDiagPartV2\n=================================\n\n`#include \u003carray_ops.h\u003e`\n\nReturns the batched diagonal part of a batched tensor.\n\nSummary\n-------\n\nReturns a tensor with the `k[0]`-th to `k[1]`-th diagonals of the batched `input`.\n\nAssume `input` has `r` dimensions `[I, J, ..., L, M, N]`. Let `max_diag_len` be the maximum length among all diagonals to be extracted, `max_diag_len = min(M + min(k[1], 0), N + min(-k[0], 0))` Let `num_diags` be the number of diagonals to extract, `num_diags = k[1] - k[0] + 1`.\n\nIf `num_diags == 1`, the output tensor is of rank `r - 1` with shape `[I, J, ..., L, max_diag_len]` and values:\n\n\u003cbr /\u003e\n\n```text\ndiagonal[i, j, ..., l, n]\n = input[i, j, ..., l, n+y, n+x] ; when 0 \u003c= n-y \u003c M and 0 \u003c= n-x \u003c N,\n 0 ; otherwise.\n```\nwhere `y = max(-k[1], 0)`, `x = max(k[1], 0)`.\n\n\u003cbr /\u003e\n\nOtherwise, the output tensor has rank `r` with dimensions `[I, J, ..., L, num_diags, max_diag_len]` with values:\n\n\u003cbr /\u003e\n\n```text\ndiagonal[i, j, ..., l, m, n]\n = input[i, j, ..., l, n+y, n+x] ; when 0 \u003c= n-y \u003c M and 0 \u003c= n-x \u003c N,\n 0 ; otherwise.\n```\nwhere `d = k[1] - m`, `y = max(-d, 0)`, and `x = max(d, 0)`.\n\n\u003cbr /\u003e\n\nThe input must be at least a matrix.\n\nFor example:\n\n\n```text\ninput = np.array([[[1, 2, 3, 4], # Input shape: (2, 3, 4)\n [5, 6, 7, 8],\n [9, 8, 7, 6]],\n [[5, 4, 3, 2],\n [1, 2, 3, 4],\n [5, 6, 7, 8]]])\n```\n\n\u003cbr /\u003e\n\n\n```scdoc\n# A main diagonal from each batch.\ntf.matrix_diag_part(input) ==\u003e [[1, 6, 7], # Output shape: (2, 3)\n [5, 2, 7]]\n```\n\n\u003cbr /\u003e\n\n\n```scdoc\n# A superdiagonal from each batch.\ntf.matrix_diag_part(input, k = 1)\n ==\u003e [[2, 7, 6], # Output shape: (2, 3)\n [4, 3, 8]]\n```\n\n\u003cbr /\u003e\n\n\n```scdoc\n# A tridiagonal band from each batch.\ntf.matrix_diag_part(input, k = (-1, 1))\n ==\u003e [[[2, 7, 6], # Output shape: (2, 3, 3)\n [1, 6, 7],\n [5, 8, 0]],\n [[4, 3, 8],\n [5, 2, 7],\n [1, 6, 0]]]\n```\n\n\u003cbr /\u003e\n\n\n```scdoc\n# Padding = 9\ntf.matrix_diag_part(input, k = (1, 3), padding = 9)\n ==\u003e [[[4, 9, 9], # Output shape: (2, 3, 3)\n [3, 8, 9],\n [2, 7, 6]],\n [[2, 9, 9],\n [3, 4, 9],\n [4, 3, 8]]]\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 `r` tensor where `r \u003e= 2`.\n- k: Diagonal offset(s). Positive value means superdiagonal, 0 refers to the main diagonal, and negative value means subdiagonals. `k` can be a single integer (for a single diagonal) or a pair of integers specifying the low and high ends of a matrix band. `k[0]` must not be larger than `k[1]`.\n- padding_value: The value to fill the area outside the specified diagonal band with. Default is 0.\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).\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [MatrixDiagPartV2](#classtensorflow_1_1ops_1_1_matrix_diag_part_v2_1ad3de7ab4ab1196ff0eb0a0b9712563ef)`(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, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` k, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` padding_value)` ||\n\n| ### Public attributes ||\n|-------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [diagonal](#classtensorflow_1_1ops_1_1_matrix_diag_part_v2_1a7a8892ae88249cf5f89b97544d71a59c) | `::`[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_v2_1aefc836bb535eab5db669667a152eba42) | [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_v2_1a0b20ceb05713921670ce29cf7671a152)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_matrix_diag_part_v2_1acb91e8a485455813fcd8d9d3558c793b)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_matrix_diag_part_v2_1a18e6d0e922c930c2880112f18f2ac011)`() 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### MatrixDiagPartV2\n\n```gdscript\n MatrixDiagPartV2(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n ::tensorflow::Input k,\n ::tensorflow::Input padding_value\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```"]]