tf.raw_ops.MatrixDiag
Stay organized with collections
Save and categorize content based on your preferences.
Returns a batched diagonal tensor with a given batched diagonal values.
tf.raw_ops.MatrixDiag(
diagonal, name=None
)
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)
Args |
diagonal
|
A Tensor . Rank k , where k >= 1 .
|
name
|
A name for the operation (optional).
|
Returns |
A Tensor . Has the same type as diagonal .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.raw_ops.MatrixDiag\n\n\u003cbr /\u003e\n\nReturns a batched diagonal tensor with a given batched diagonal values.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.raw_ops.MatrixDiag`](https://www.tensorflow.org/api_docs/python/tf/raw_ops/MatrixDiag)\n\n\u003cbr /\u003e\n\n tf.raw_ops.MatrixDiag(\n diagonal, name=None\n )\n\nGiven a `diagonal`, this operation returns a tensor with the `diagonal` and\neverything else padded with zeros. The diagonal is computed as follows:\n\nAssume `diagonal` has `k` dimensions `[I, J, K, ..., N]`, then the output is a\ntensor of rank `k+1` with dimensions \\[I, J, K, ..., N, N\\]\\` where:\n\n`output[i, j, k, ..., m, n] = 1{m=n} * diagonal[i, j, k, ..., n]`.\n\n#### For example:\n\n # 'diagonal' is [[1, 2, 3, 4], [5, 6, 7, 8]]\n\n and diagonal.shape = (2, 4)\n\n tf.matrix_diag(diagonal) ==\u003e [[[1, 0, 0, 0]\n [0, 2, 0, 0]\n [0, 0, 3, 0]\n [0, 0, 0, 4]],\n [[5, 0, 0, 0]\n [0, 6, 0, 0]\n [0, 0, 7, 0]\n [0, 0, 0, 8]]]\n\n which has shape (2, 4, 4)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------|---------------------------------------|\n| `diagonal` | A `Tensor`. Rank `k`, where `k \u003e= 1`. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Tensor`. Has the same type as `diagonal`. ||\n\n\u003cbr /\u003e"]]