tensorflow:: عملیات:: MatrixSetDiagV2
#include <array_ops.h>یک تانسور ماتریس دسته بندی شده با مقادیر قطری دسته بندی شده جدید را برمیگرداند.
خلاصه
با توجه به input و diagonal ، این عملیات یک تانسور با همان شکل و مقادیر input برمیگرداند، به جز قطرهای مشخص شده از درونیترین ماتریسها. این مقادیر با مقادیر موجود در diagonal بازنویسی میشوند.
input دارای r+1 بُعد است [I, J, ..., L, M, N] . وقتی k اسکالر یا k[0] == k[1] ، diagonal دارای r بُعد است [I, J, ..., L, max_diag_len] . در غیر این صورت، دارای r+1 بُعد است [I, J, ..., L, num_diags, max_diag_len] . num_diags تعداد قطرها است، num_diags = k[1] - k[0] + 1 max_diag_len طولانیترین قطر در بازه [k[0], k[1]] است، max_diag_len = min(M + min(k[1], 0), N + min(-k[0], 0))
خروجی یک تانسور با مرتبه k+1 با ابعاد [I, J, ..., L, M, N] است. اگر k اسکالر باشد یا k[0] == k[1] :
output[i, j, ..., l, m, n]
= diagonal[i, j, ..., l, n-max(k[1], 0)] ; if n - m == k[1]
input[i, j, ..., l, m, n] ; otherwiseدر غیر این صورت،
output[i, j, ..., l, m, n]
= diagonal[i, j, ..., l, diag_index, index_in_diag] ; if k[0] <= d <= k[1]
input[i, j, ..., l, m, n] ; otherwised = n - m ، diag_index = k[1] - d و index_in_diag = n - max(d, 0) .برای مثال:
# The main diagonal. input = np.array([[[7, 7, 7, 7], # Input shape: (2, 3, 4) [7, 7, 7, 7], [7, 7, 7, 7]], [[7, 7, 7, 7], [7, 7, 7, 7], [7, 7, 7, 7]]]) diagonal = np.array([[1, 2, 3], # Diagonal shape: (2, 3) [4, 5, 6]]) tf.matrix_set_diag(diagonal) ==> [[[1, 7, 7, 7], # Output shape: (2, 3, 4) [7, 2, 7, 7], [7, 7, 3, 7]], [[4, 7, 7, 7], [7, 5, 7, 7], [7, 7, 6, 7]]]
# A superdiagonal (per batch). tf.matrix_set_diag(diagonal, k = 1) ==> [[[7, 1, 7, 7], # Output shape: (2, 3, 4) [7, 7, 2, 7], [7, 7, 7, 3]], [[7, 4, 7, 7], [7, 7, 5, 7], [7, 7, 7, 6]]]
# A band of diagonals.
diagonals = np.array([[[1, 2, 3], # Diagonal shape: (2, 2, 3)
[4, 5, 0]],
[[6, 1, 2],
[3, 4, 0]]])
tf.matrix_set_diag(diagonals, k = (-1, 0))
==> [[[1, 7, 7, 7], # Output shape: (2, 3, 4)
[4, 2, 7, 7],
[0, 5, 3, 7]],
[[6, 7, 7, 7],
[3, 1, 7, 7],
[7, 4, 2, 7]]]Arguments:
- scope: A Scope object
- input: Rank
r+1, wherer >= 1. - diagonal: Rank
rwhenkis an integer ork[0] == k[1]. Otherwise, it has rankr+1.k >= 1. - 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].
Returns:
Output: Rankr+1, withoutput.shape = input.shape.
Constructors and Destructors |
|
|---|---|
MatrixSetDiagV2(const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input diagonal, ::tensorflow::Input k)
|
Public attributes |
|
|---|---|
operation
|
|
output
|
|
Public functions |
|
|---|---|
node() const
|
::tensorflow::Node *
|
operator::tensorflow::Input() const
|
|
operator::tensorflow::Output() const
|
|
Public attributes
operation
Operation operation
خروجی
::tensorflow::Output output
کارکردهای عمومی
MatrixSetDiagV2
MatrixSetDiagV2( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input diagonal, ::tensorflow::Input k )
گره
::tensorflow::Node * node() const
عملگر::tensorflow::ورودی
operator::tensorflow::Input() const
عملگر::tensorflow::خروجی
operator::tensorflow::Output() const
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2026-11-05 بهوقت ساعت هماهنگ جهانی.