tensorflow::ops::MatrixDiagV2
#include <array_ops.h>Returns a batched diagonal tensor with given batched diagonal values.
Résumé
Returns a tensor with the contents in diagonal as k[0] -th to k[1] -th diagonals of a matrix, with everything else padded with padding . num_rows and num_cols specify the dimension of the innermost matrix of the output. If both are not specified, the op assumes the innermost matrix is square and infers its size from k and the innermost dimension of diagonal . If only one of them is specified, the op assumes the unspecified value is the smallest possible based on other criteria.
Soit diagonal de dimension r [I, J, ..., L, M, N] . Le tenseur de sortie est de rang r+1 et de forme [I, J, ..., L, M, num_rows, num_cols] lorsqu'une seule diagonale est donnée ( k est un entier ou k[0] == k[1] ). Sinon, il est de rang r et de forme [I, J, ..., L, num_rows, num_cols] .
The second innermost dimension of diagonal has double meaning. When k is scalar or k[0] == k[1] , M is part of the batch size [I, J, ..., M], and the output tensor is:
output[i, j, ..., l, m, n]
= diagonal[i, j, ..., l, n-max(d_upper, 0)] ; if n - m == d_upper
output[i, j, ..., l, m, n] ; otherwise Otherwise, M is treated as the number of diagonals for the matrix in the same batch ( M = k[1]-k[0]+1 ), and the output tensor is:
output[i, j, ..., l, m, n]
= diagonal[i, j, ..., l, k[1]-d, n-max(d, 0)] ; if d_lower <= d <= d_upper
input[i, j, ..., l, m, n] ; otherwised = n - mPar exemple:
# The main diagonal. diagonal = np.array([[1, 2, 3, 4], # Input shape: (2, 4) [5, 6, 7, 8]]) tf.matrix_diag(diagonal) ==> [[[1, 0, 0, 0], # Output shape: (2, 4, 4) [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]], [[5, 0, 0, 0], [0, 6, 0, 0], [0, 0, 7, 0], [0, 0, 0, 8]]]
# A superdiagonal (per batch). diagonal = np.array([[1, 2, 3], # Input shape: (2, 3) [4, 5, 6]]) tf.matrix_diag(diagonal, k = 1) ==> [[[0, 1, 0, 0], # Output shape: (2, 4, 4) [0, 0, 2, 0], [0, 0, 0, 3], [0, 0, 0, 0]], [[0, 4, 0, 0], [0, 0, 5, 0], [0, 0, 0, 6], [0, 0, 0, 0]]]
# A band of diagonals. diagonals = np.array([[[1, 2, 3], # Input shape: (2, 2, 3) [4, 5, 0]], [[6, 7, 9], [9, 1, 0]]]) tf.matrix_diag(diagonals, k = (-1, 0)) ==> [[[1, 0, 0], # Output shape: (2, 3, 3) [4, 2, 0], [0, 5, 3]], [[6, 0, 0], [9, 7, 0], [0, 1, 9]]]
# Rectangular matrix. diagonal = np.array([1, 2]) # Input shape: (2) tf.matrix_diag(diagonal, k = -1, num_rows = 3, num_cols = 4) ==> [[0, 0, 0, 0], # Output shape: (3, 4) [1, 0, 0, 0], [0, 2, 0, 0]]
# Rectangular matrix with inferred num_cols and padding = 9. tf.matrix_diag(diagonal, k = -1, num_rows = 3, padding = 9) ==> [[9, 9], # Output shape: (3, 2) [1, 9], [9, 2]]
Arguments :
- portée : un objet Scope
- diagonale : Rang
r, oùr >= 1 - k : Décalage(s) diagonal(s). Une valeur positive correspond à la diagonale supérieure, 0 à la diagonale principale et une valeur négative aux sous-diagonales.
kpeut être un entier unique (pour une seule diagonale) ou une paire d’entiers spécifiant les limites inférieure et supérieure d’une bande de la matrice.k[0]ne doit pas être supérieur àk[1]. - num_rows : Le nombre de lignes de la matrice de sortie. Si cette valeur n’est pas fournie, l’opérateur suppose que la matrice de sortie est une matrice carrée et déduit la taille de la matrice à partir de k et de la dimension la plus interne de la
diagonal. - num_cols : Nombre de colonnes de la matrice de sortie. Si cette valeur n’est pas fournie, l’opérateur suppose que la matrice de sortie est carrée et déduit sa taille à partir de k et de la dimension la plus interne de
diagonal. - padding_value: The number to fill the area outside the specified diagonal band with. Default is 0.
Retours :
-
Output: Has rankr+1whenkis an integer ork[0] == k[1], rankrotherwise.
Constructeurs et destructeurs | |
|---|---|
MatrixDiagV2 (const :: tensorflow::Scope & scope, :: tensorflow::Input diagonal, :: tensorflow::Input k, :: tensorflow::Input num_rows, :: tensorflow::Input num_cols, :: tensorflow::Input padding_value) |
attributs publics | |
|---|---|
operation | |
output | |
fonctions publiques | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
attributs publics
opération
Operation operation
sortir
::tensorflow::Output output
fonctions publiques
MatrixDiagV2
MatrixDiagV2( const ::tensorflow::Scope & scope, ::tensorflow::Input diagonal, ::tensorflow::Input k, ::tensorflow::Input num_rows, ::tensorflow::Input num_cols, ::tensorflow::Input padding_value )
nœud
::tensorflow::Node * node() const
opérateur::tensorflow::Entrée
operator::tensorflow::Input() const
opérateur::tensorflow::Sortie
operator::tensorflow::Output() const