संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
टेंसरफ़्लो:: ऑप्स:: निदान
#include <array_ops.h>
किसी दिए गए विकर्ण मान के साथ एक विकर्ण टेंसर लौटाता है।
सारांश
एक diagonal
देखते हुए, यह ऑपरेशन diagonal
के साथ एक टेंसर लौटाता है और बाकी सब कुछ शून्य के साथ गद्देदार होता है। विकर्ण की गणना इस प्रकार की जाती है:
मान लें कि diagonal
आयाम [D1,..., Dk] हैं, तो आउटपुट आयामों के साथ रैंक 2k का एक टेंसर है [D1,..., Dk, D1,..., Dk] जहां:
output[i1,..., ik, i1,..., ik] = diagonal[i1, ..., ik]
और 0 हर जगह।
उदाहरण के लिए:
# 'diagonal' is [1, 2, 3, 4]
tf.diag(diagonal) ==> [[1, 0, 0, 0]
[0, 2, 0, 0]
[0, 0, 3, 0]
[0, 0, 0, 4]]
तर्क:
- स्कोप: एक स्कोप ऑब्जेक्ट
- विकर्ण: रैंक k टेंसर जहां k अधिकतम 1 है।
रिटर्न:
सार्वजनिक गुण
सार्वजनिक समारोह
नोड
::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-27 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया."],[],[],null,["# tensorflow::ops::Diag Class Reference\n\ntensorflow::ops::Diag\n=====================\n\n`#include \u003carray_ops.h\u003e`\n\nReturns a diagonal tensor with a given diagonal values.\n\nSummary\n-------\n\nGiven a `diagonal`, this operation returns a tensor with the `diagonal` and everything else padded with zeros. The diagonal is computed as follows:\n\nAssume `diagonal` has dimensions \\[D1,..., Dk\\], then the output is a tensor of rank 2k with dimensions \\[D1,..., Dk, D1,..., Dk\\] where:\n\n`output[i1,..., ik, i1,..., ik] = diagonal[i1, ..., ik]` and 0 everywhere else.\n\nFor example:\n\n\n```text\n# 'diagonal' is [1, 2, 3, 4]\ntf.diag(diagonal) ==\u003e [[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\nArguments:\n\n- scope: A [Scope](/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- diagonal: Rank k tensor where k is at most 1.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): The output tensor.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [Diag](#classtensorflow_1_1ops_1_1_diag_1a5beb111139305546f475c8687a35ce26)`(const ::`[tensorflow::Scope](/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` diagonal)` ||\n\n| ### Public attributes ||\n|----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_diag_1a051fe6a94969df559f77f9da31685e59) | [Operation](/versions/r2.3/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_diag_1a0928ff530cf6fe0c4b3f4f1e6e1a419b) | `::`[tensorflow::Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public functions ||\n|----------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_diag_1a53b2f11c3a488f759bd883f16f5bbbf2)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_diag_1ac6d654e5b82ac6954ce4b60948da65d9)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_diag_1ae8e07573b96ad7b6b69b9c4d4d4016d8)`() const ` | ` ` ` ` |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### output\n\n```text\n::tensorflow::Output output\n``` \n\nPublic functions\n----------------\n\n### Diag\n\n```gdscript\n Diag(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input diagonal\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```"]]