텐서플로우:: 작전:: MatrixSetDiagV3

#include <array_ops.h>

새로운 배치 대각선 값을 갖는 배치 행렬 텐서를 반환합니다.

요약

inputdiagonal 주어지면 이 연산은 가장 안쪽 행렬의 지정된 대각선을 제외하고 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))

출력은 [I, J, ..., L, M, N] 차원을 갖는 k+1 순위의 텐서입니다. 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]                         ; otherwise
여기서 d = n - m , diag_index = k[1] - dindex_in_diag = n - max(d, 0) + offset .

대각선 정렬이 오른쪽인 경우를 제외하고 offset 은 0입니다.

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

예를 들어:

# 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(input, 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(input, 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([[[0, 9, 1],  # Diagonal shape: (2, 4, 3)
                       
[6, 5, 8],
                       
[1, 2, 3],
                       
[4, 5, 0]],
                     
[[0, 1, 2],
                       
[5, 6, 4],
                       
[6, 1, 2],
                       
[3, 4, 0]]])
tf
.matrix_set_diag(input, diagonals, k = (-1, 2))
 
==> [[[1, 6, 9, 7],  # Output shape: (2, 3, 4)
       
[4, 2, 5, 1],
       
[7, 5, 3, 8]],
       
[[6, 5, 1, 7],
       
[3, 1, 6, 2],
       
[7, 4, 2, 4]]]

# LEFT_RIGHT alignment.
diagonals
= np.array([[[9, 1, 0],  # Diagonal shape: (2, 4, 3)
                       
[6, 5, 8],
                       
[1, 2, 3],
                       
[0, 4, 5]],
                     
[[1, 2, 0],
                       
[5, 6, 4],
                       
[6, 1, 2],
                       
[0, 3, 4]]])
tf
.matrix_set_diag(input, diagonals, k = (-1, 2), align="LEFT_RIGHT")
 
==> [[[1, 6, 9, 7],  # Output shape: (2, 3, 4)
       
[4, 2, 5, 1],
       
[7, 5, 3, 8]],
       
[[6, 5, 1, 7],
       
[3, 1, 6, 2],
       
[7, 4, 2, 4]]]

  


 

Arguments:


         
  • scope: A Scope object

  •      
  • input: Rank r+1, where r >= 1.

  •      
  • diagonal: Rank r when k is an integer or k[0] == k[1]. Otherwise, it has rank r+1. k >= 1.

  •      
  • k: Diagonal offset(s). Positive value means superdiagonal, 0 refers to the main diagonal, and negative value means subdiagonals. k can 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 than k[1].

  •    


 

Optional attributes (see Attrs):


         
  • align: Some diagonals are shorter than max_diag_len and need to be padded. align is 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: Rank r+1, with output.shape = input.shape.

  •    


 

   

     

   

   

     

   

   

     

   

 

       

Constructors and Destructors


     

       
MatrixSetDiagV3(const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input diagonal, ::tensorflow::Input k)
       

     

       
MatrixSetDiagV3(const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input diagonal, ::tensorflow::Input k, const MatrixSetDiagV3::Attrs & attrs)
       

     

 

   

     

   

   

     

     

   

   

     

     

   

 

       

Public attributes


     

       
operation
     

       

         
Operation
       

     

       
output
     

       

         
::tensorflow::Output
       

     

 

   

     

   

   

     

     

   

   

     

     

   

   

     

     

   

 

       

Public functions


     

       
node() const
     

       

         
::tensorflow::Node *
       

     

       
operator::tensorflow::Input() const
     

       

         

       

     

       
operator::tensorflow::Output() const
     

       

         

       

     

 

   

     

   

   

     

     

   

 

       

Public static functions


     

       
Align(StringPiece x)
     

       

         
Attrs
       

     

 

   

     

   

   

     

     

   

 

       

Structs


     

       
tensorflow::ops::MatrixSetDiagV3::Attrs
     

       

Optional attribute setters for MatrixSetDiagV3.


     

 

Public attributes


 

   

operation


   

산출

 

공공 기능

 MatrixSetDiagV3

 

MatrixSetDiagV3

 

마디

 

 연산자::텐서플로우::입력

 

 연산자::텐서플로우::출력

 

 공개 정적 함수

 맞추다