Aliases:
tf.linalg.set_diag
tf.matrix_set_diag
tf.linalg.set_diag(
input,
diagonal,
name=None
)
Defined in generated file: tensorflow/python/ops/gen_array_ops.py
.
Returns a batched matrix tensor with new batched diagonal values.
Given input
and diagonal
, this operation returns a tensor with the
same shape and values as input
, except for the main diagonal of the
innermost matrices. These will be overwritten by the values in diagonal
.
The output is computed as follows:
Assume input
has k+1
dimensions [I, J, K, ..., M, N]
and diagonal
has
k
dimensions [I, J, K, ..., min(M, N)]
. Then the output is a
tensor of rank k+1
with dimensions [I, J, K, ..., M, N]
where:
output[i, j, k, ..., m, n] = diagonal[i, j, k, ..., n]
form == n
.output[i, j, k, ..., m, n] = input[i, j, k, ..., m, n]
form != n
.
Args:
input
: ATensor
. Rankk+1
, wherek >= 1
.diagonal
: ATensor
. Must have the same type asinput
. Rankk
, wherek >= 1
.name
: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as input
.