tensorflow:: ops:: MatrixDiagPartV2
#include <array_ops.h>Devuelve la parte diagonal agrupada de un tensor agrupado.
Resumen
Devuelve un tensor con las diagonales k[0] a k[1] de la input por lotes.
Supongamos que input tiene r dimensiones [I, J, ..., L, M, N] . Sea max_diag_len la longitud máxima entre todas las diagonales a extraer, max_diag_len = min(M + min(k[1], 0), N + min(-k[0], 0)) Sea num_diags el número de diagonales a extraer, num_diags = k[1] - k[0] + 1 .
Si num_diags == 1 , el tensor de salida es de rango r - 1 con forma [I, J, ..., L, max_diag_len] y valores:
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) . De lo contrario, el tensor de salida tiene rango r con dimensiones [I, J, ..., L, num_diags, max_diag_len] con valores:
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) , y x = max(d, 0) .La entrada debe ser al menos una matriz.
Por ejemplo:
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]]]
Argumentos:
- ámbito: Un objeto de ámbito
- Entrada: Tensor de rango
rdonder >= 2. - k: Desplazamiento(s) diagonal(es). Un valor positivo indica superdiagonal, 0 se refiere a la diagonal principal y un valor negativo indica subdiagonal.
kpuede ser un solo entero (para una sola diagonal) o un par de enteros que especifican los extremos inferior y superior de una banda de la matriz.k[0]no debe ser mayor quek[1]. - padding_value: El valor con el que se rellenará el área fuera de la banda diagonal especificada. El valor predeterminado es 0.
Devoluciones:
-
Output: The extracted diagonal(s).
Constructores y destructores | |
|---|---|
MatrixDiagPartV2 (const :: tensorflow::Scope & scope, :: tensorflow::Input input, :: tensorflow::Input k, :: tensorflow::Input padding_value) |
Atributos públicos | |
|---|---|
diagonal | |
operation | |
Funciones públicas | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
Atributos públicos
diagonal
::tensorflow::Output diagonal
operación
Operation operation
Funciones públicas
MatrixDiagParteV2
MatrixDiagPartV2( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input k, ::tensorflow::Input padding_value )
nodo
::tensorflow::Node * node() const
operador::tensorflow::Input
operator::tensorflow::Input() const
operador::tensorflow::Salida
operator::tensorflow::Output() const