T - data type for diagonal() output@Operator public final class MatrixDiagPart<T> extends PrimitiveOp implements Operand<T>
This operation returns a tensor with the `diagonal` part of the batched `input`. The `diagonal` part is computed as follows:
Assume `input` has `k` dimensions `[I, J, K, ..., M, N]`, then the output is a tensor of rank `k - 1` with dimensions `[I, J, K, ..., min(M, N)]` where:
`diagonal[i, j, k, ..., n] = input[i, j, k, ..., n, n]`.
The input must be at least a matrix.
For example:
# 'input' is [[[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]]]
and input.shape = (2, 4, 4)
tf.matrix_diag_part(input) ==> [[1, 2, 3, 4], [5, 6, 7, 8]]
which has shape (2, 4)
operation| Modifier and Type | Method and Description |
|---|---|
Output<T> |
asOutput()
Returns the symbolic handle of a tensor.
|
static <T> MatrixDiagPart<T> |
create(Scope scope,
Operand<T> input)
Factory method to create a class to wrap a new MatrixDiagPart operation to the graph.
|
Output<T> |
diagonal()
The extracted diagonal(s) having shape
`diagonal.shape = input.shape[:-2] + [min(input.shape[-2:])]`.
|
equals, hashCode, toStringpublic static <T> MatrixDiagPart<T> create(Scope scope, Operand<T> input)
scope - current graph scopeinput - Rank `k` tensor where `k >= 2`.public Output<T> diagonal()
public Output<T> asOutput()
OperandInputs to TensorFlow operations are outputs of another TensorFlow operation. This method is used to obtain a symbolic handle that represents the computation of the input.
asOutput in interface Operand<T>OperationBuilder.addInput(Output)Copyright © 2015–2019. All rights reserved.