tensorflow:: ops:: MatrixDiagPartV2

#include <array_ops.h>

バッチ化されたテンソルの、バッチ化された対角部分を返します。

まとめ

バッチinputのk[0]番目からk[1]番目までの対角成分を持つテンソルを返します。

Assume 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 .

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) 、 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 value = 9
tf.matrix_diag_part(input, k = (1, 3), padding_value = 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単一の整数 (単一の対角の場合) または行列バンドの下限と上限を指定する整数のペアです。k k[0] k[1]より大きくあってはなりません。
  • padding_value: 指定された対角線の外側の領域を埋める値。デフォルト値は0です。

返品:

  • Output :抽出された対角線。

コンストラクターとデストラクタ

MatrixDiagPartV2 (const :: tensorflow::Scope & scope, :: tensorflow::Input input, :: tensorflow::Input k, :: tensorflow::Input padding_value)

公開属性

diagonal
operation

公的機能

node () const
::tensorflow::Node *
operator::tensorflow::Input () const
operator::tensorflow::Output () const

公開属性

対角線

::tensorflow::Output diagonal

手術

Operation operation

公的機能

MatrixDiagPartV2

 MatrixDiagPartV2(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  ::tensorflow::Input k,
  ::tensorflow::Input padding_value
)

ノード

::tensorflow::Node * node() const 

operator::tensorflow::Input

 operator::tensorflow::Input() const 

operator::tensorflow::Output

 operator::tensorflow::Output() const