MatrixDiag
tensorflow C++ API
Returns a batched diagonal tensor with a given batched diagonal values.
Summary
Given adiagonal
, this operation returns a tensor with thediagonal
and everything else padded with zeros. The diagonal is computed as follows:
Assumediagonal
hask
dimensions[I, J, K, ..., N]
, then the output is a tensor of rankk+1
with dimensions [I, J, K, ..., N, N]` where:
output[i, j, k, ..., m, n] = 1{m=n} * diagonal[i, j, k, ..., n]
.
For example:
``` 'diagonal' is [[1, 2, 3, 4], [5, 6, 7, 8]]
and diagonal.shape = (2, 4)
tf.matrix_diag(diagonal) ==> [[[1, 0, 0, 0] [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]]]
which has shape (2, 4, 4) ```
Arguments:
Returns:
MatrixDiag block
Source link :https://github.com/EXPNUNI/enuSpaceTensorflow/blob/master/enuSpaceTensorflow/tf_array_ops.cpp
Argument:
- Scope scope : A Scope object (A scope is generated automatically each page. A scope is not connected.)
- Input diagonal : A 1-D
Tensor
type ofint32
,int64
(Must be one integer type).
Output:
- Output output : Output object of MatrixBandPart class object.
Result:
- std::vector(Tensor)
result_output
: ATensor
.
Using Method
※ tensorflow 1.3 does not support Windows