tensorflow:: ops:: MatrixDiagPartV3
#include <array_ops.h>تُعيد هذه الدالة الجزء القطري المجمع من موتر مجمع.
ملخص
يُرجع موترًا يحتوي على الأقطار من k[0] إلى k[1] input المجمعة.
لنفترض أن 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 ، فإن موتر الإخراج يكون من الرتبة r - 1 وله شكل [I, J, ..., L, max_diag_len] والقيم التالية:
diagonal[i, j, ..., l, n]
= input[i, j, ..., l, n+y, n+x] ; if 0 <= n+y < M and 0 <= n+x < N,
padding_value ; 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] ; if 0 <= n+y < M and 0 <= n+x < N,
padding_value ; otherwise.d = k[1] - m ، y = max(-d, 0) - offset ، و x = max(d, 0) - offset . تكون offset صفرًا إلا عندما يكون محاذاة القطر إلى اليمين.
offset = max_diag_len - diag_len(d) ; if (`align` in {RIGHT_LEFT, RIGHT_RIGHT} and `d >= 0`) or (`align` in {LEFT_RIGHT, RIGHT_RIGHT} and `d <= 0`) 0 ; otherwise
diag_len(d) = min(cols - max(d, 0), rows + min(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 band from each batch. tf.matrix_diag_part(input, k = (-1, 2)) ==> [[[0, 3, 8], # Output shape: (2, 4, 3) [2, 7, 6], [1, 6, 7], [5, 8, 0]], [[0, 3, 4], [4, 3, 8], [5, 2, 7], [1, 6, 0]]]
# LEFT_RIGHT alignment. tf.matrix_diag_part(input, k = (-1, 2), align="LEFT_RIGHT") ==> [[[3, 8, 0], # Output shape: (2, 4, 3) [2, 7, 6], [1, 6, 7], [0, 5, 8]], [[3, 4, 0], [4, 3, 8], [5, 2, 7], [0, 1, 6]]]
# max_diag_len can be shorter than the main diagonal.
tf.matrix_diag_part(input, k = (-2, -1))
==> [[[5, 8],
[9, 0]],
[[1, 6],
[5, 0]]]# padding_value = 9 tf.matrix_diag_part(input, k = (1, 3), padding_value = 9) ==> [[[9, 9, 4], # Output shape: (2, 3, 3) [9, 3, 8], [2, 7, 6]], [[9, 9, 2], [9, 3, 4], [4, 3, 8]]]
Arguments:
- scope: A Scope object
- input: Rank
rtensor wherer >= 2. - k: Diagonal offset(s). Positive value means superdiagonal, 0 refers to the main diagonal, and negative value means subdiagonals.
kcan 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 thank[1]. - padding_value: The value to fill the area outside the specified diagonal band with. Default is 0.
Optional attributes (see Attrs):
- align: Some diagonals are shorter than
max_diag_lenand need to be padded.alignis a string specifying how superdiagonals and subdiagonals should be aligned, respectively. There are four possible alignments: "RIGHT_LEFT" (default), "LEFT_RIGHT", "LEFT_LEFT", and "RIGHT_RIGHT". "RIGHT_LEFT" aligns superdiagonals to the right (left-pads the row) and subdiagonals to the left (right-pads the row). It is the packing format LAPACK uses. cuSPARSE uses "LEFT_RIGHT", which is the opposite alignment.
Returns:
Output: The extracted diagonal(s).
Constructors and Destructors |
|
|---|---|
MatrixDiagPartV3(const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input k, ::tensorflow::Input padding_value)
|
|
MatrixDiagPartV3(const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input k, ::tensorflow::Input padding_value, const MatrixDiagPartV3::Attrs & attrs)
|
Public attributes |
|
|---|---|
diagonal
|
|
operation
|
|
Public functions |
|
|---|---|
node() const
|
::tensorflow::Node *
|
operator::tensorflow::Input() const
|
|
operator::tensorflow::Output() const
|
|
Public static functions |
|
|---|---|
Align(StringPiece x)
|
|
Structs |
|
|---|---|
|
tensorflow:: |
Optional attribute setters for MatrixDiagPartV3. |
Public attributes
diagonal
::tensorflow::Output diagonal
عملية
Operation operation
الوظائف العامة
MatrixDiagPartV3
MatrixDiagPartV3( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input k, ::tensorflow::Input padding_value )
MatrixDiagPartV3
MatrixDiagPartV3( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input k, ::tensorflow::Input padding_value, const MatrixDiagPartV3::Attrs & attrs )
العقدة
::tensorflow::Node * node() const
operator::tensorflow::Input
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
الدوال الثابتة العامة
محاذاة
Attrs Align( StringPiece x )
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2026-11-05 (حسب التوقيت العالمي المتفَّق عليه)