Have a question? Connect with the community at the TensorFlow Forum Visit Forum

TensorDiag

public final class TensorDiag

Returns a diagonal tensor with a given diagonal values.

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]]
 

Constants

String OP_NAME The name of this op, as known by TensorFlow core engine

Public Methods

Output <T>
asOutput ()
Returns the symbolic handle of the tensor.
static <T extends TType > TensorDiag <T>
create ( Scope scope, Operand <T> diagonal)
Factory method to create a class wrapping a new TensorDiag operation.
Output <T>

Inherited Methods

Constants

public static final String OP_NAME

The name of this op, as known by TensorFlow core engine

Constant Value: "Diag"

Public Methods

public Output <T> asOutput ()

Returns the symbolic handle of the tensor.

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.

public static TensorDiag <T> create ( Scope scope, Operand <T> diagonal)

Factory method to create a class wrapping a new TensorDiag operation.

Parameters
scope current scope
diagonal Rank k tensor where k is at most 1.
Returns
  • a new instance of TensorDiag

public Output <T> output ()