T
- data type for output()
output@Operator(group="linalg") public final class TensorDiag<T> extends PrimitiveOp implements Operand<T>
Given a `diagonal`, this operation returns a tensor with the `diagonal` and everything else padded with zeros. The diagonal is computed as follows:
Assume `diagonal` has dimensions [D1,..., Dk], then the output is a tensor of rank 2k with dimensions [D1,..., Dk, D1,..., Dk] where:
`output[i1,..., ik, i1,..., ik] = diagonal[i1, ..., ik]` and 0 everywhere else.
For example:
# 'diagonal' is [1, 2, 3, 4]
tf.diag(diagonal) ==> [[1, 0, 0, 0]
[0, 2, 0, 0]
[0, 0, 3, 0]
[0, 0, 0, 4]]
operation
Modifier and Type | Method and Description |
---|---|
Output<T> |
asOutput()
Returns the symbolic handle of a tensor.
|
static <T> TensorDiag<T> |
create(Scope scope,
Operand<T> diagonal)
Factory method to create a class wrapping a new TensorDiag operation.
|
Output<T> |
output() |
equals, hashCode, op, toString
public static <T> TensorDiag<T> create(Scope scope, Operand<T> diagonal)
scope
- current scopediagonal
- Rank k tensor where k is at most 1.public Output<T> asOutput()
Operand
Inputs 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 © 2022. All rights reserved.