Returns a diagonal tensor with given diagonal values.
Given a diagonal, this operation returns a tensor with the diagonal and everything else padded with zeros.
Assume the input has dimensions [D1,..., Dk], then the output is a tensor of rank 2k with dimensions [D1,..., Dk, D1,..., Dk]
[D1,..., Dk]
[D1,..., Dk, D1,..., Dk]
const x = tf.tensor1d([1, 2, 3, 4]);tf.diag(x).print() Copy
const x = tf.tensor1d([1, 2, 3, 4]);tf.diag(x).print()
const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [4, 2])tf.diag(x).print() Copy
const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [4, 2])tf.diag(x).print()
The input tensor.
Generated using TypeDoc
Returns a diagonal tensor with given diagonal values.
Given a diagonal, this operation returns a tensor with the diagonal and everything else padded with zeros.
Assume the input has dimensions
[D1,..., Dk]
, then the output is a tensor of rank 2k with dimensions[D1,..., Dk, D1,..., Dk]