tf.matrix_set_diag

tf.matrix_set_diag

tf.matrix_set_diag

matrix_set_diag(
    input,
    diagonal,
    name=None
)

Defined in tensorflow/python/ops/gen_array_ops.py.

See the guide: Math > Matrix Math Functions

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] for m == n.
  • output[i, j, k, ..., m, n] = input[i, j, k, ..., m, n] for m != n.

Args:

  • input: A Tensor. Rank k+1, where k >= 1.
  • diagonal: A Tensor. Must have the same type as input. Rank k, where k >= 1.
  • name: A name for the operation (optional).

Returns:

A Tensor. Has the same type as input. Rank k+1, with output.shape = input.shape.

© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/matrix_set_diag

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部