T
- data type for output()
output@Operator(group="linalg") public final class Diag<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 `k` dimensions `[I, J, K, ..., N]`, then the output is a tensor of rank `k+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)
operation
Modifier and Type | Method and Description |
---|---|
Output<T> |
asOutput()
Returns the symbolic handle of a tensor.
|
static <T> Diag<T> |
create(Scope scope,
Operand<T> diagonal)
Factory method to create a class wrapping a new Diag operation.
|
Output<T> |
output()
Rank `k+1`, with `output.shape = diagonal.shape + [diagonal.shape[-1]]`.
|
equals, hashCode, op, toString
public static <T> Diag<T> create(Scope scope, Operand<T> diagonal)
scope
- current scopediagonal
- Rank `k`, where `k >= 1`.public Output<T> output()
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.