tf.raw_ops.MatrixBandPart
bookmark_borderbookmark
Stay organized with collections
Save and categorize content based on your preferences.
Copy a tensor setting everything outside a central band in each innermost matrix to zero.
View aliases
Compat aliases for migration
See
Migration guide for
more details.
tf.compat.v1.raw_ops.MatrixBandPart
tf.raw_ops.MatrixBandPart(
input, num_lower, num_upper, name=None
)
The band
part is computed as follows:
Assume input
has k
dimensions [I, J, K, ..., M, N]
, then the output is a
tensor with the same shape where
band[i, j, k, ..., m, n] = in_band(m, n) * input[i, j, k, ..., m, n]
.
The indicator function
in_band(m, n) = (num_lower < 0 || (m-n) <= num_lower)) &&
(num_upper < 0 || (n-m) <= num_upper)
.
For example:
# if 'input' is [[ 0, 1, 2, 3]
# [-1, 0, 1, 2]
# [-2, -1, 0, 1]
# [-3, -2, -1, 0]],
tf.linalg.band_part(input, 1, -1) ==> [[ 0, 1, 2, 3]
[-1, 0, 1, 2]
[ 0, -1, 0, 1]
[ 0, 0, -1, 0]],
tf.linalg.band_part(input, 2, 1) ==> [[ 0, 1, 0, 0]
[-1, 0, 1, 0]
[-2, -1, 0, 1]
[ 0, -2, -1, 0]]
Useful special cases:
tf.linalg.band_part(input, 0, -1) ==> Upper triangular part.
tf.linalg.band_part(input, -1, 0) ==> Lower triangular part.
tf.linalg.band_part(input, 0, 0) ==> Diagonal.
Args |
input
|
A Tensor . Rank k tensor.
|
num_lower
|
A Tensor . Must be one of the following types: int32 , int64 .
0-D tensor. Number of subdiagonals to keep. If negative, keep entire
lower triangle.
|
num_upper
|
A Tensor . Must have the same type as num_lower .
0-D tensor. Number of superdiagonals to keep. If negative, keep
entire upper triangle.
|
name
|
A name for the operation (optional).
|
Returns |
A Tensor . Has the same type as input .
|
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.MatrixBandPart\n\n\u003cbr /\u003e\n\nCopy a tensor setting everything outside a central band in each innermost matrix to zero.\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.MatrixBandPart`](https://www.tensorflow.org/api_docs/python/tf/raw_ops/MatrixBandPart)\n\n\u003cbr /\u003e\n\n tf.raw_ops.MatrixBandPart(\n input, num_lower, num_upper, name=None\n )\n\nThe `band` part is computed as follows:\nAssume `input` has `k` dimensions `[I, J, K, ..., M, N]`, then the output is a\ntensor with the same shape where\n\n`band[i, j, k, ..., m, n] = in_band(m, n) * input[i, j, k, ..., m, n]`.\n\nThe indicator function\n\n`in_band(m, n) = (num_lower \u003c 0 || (m-n) \u003c= num_lower)) &&\n(num_upper \u003c 0 || (n-m) \u003c= num_upper)`.\n\n#### For example:\n\n # if 'input' is [[ 0, 1, 2, 3]\n # [-1, 0, 1, 2]\n # [-2, -1, 0, 1]\n # [-3, -2, -1, 0]],\n\n tf.linalg.band_part(input, 1, -1) ==\u003e [[ 0, 1, 2, 3]\n [-1, 0, 1, 2]\n [ 0, -1, 0, 1]\n [ 0, 0, -1, 0]],\n\n tf.linalg.band_part(input, 2, 1) ==\u003e [[ 0, 1, 0, 0]\n [-1, 0, 1, 0]\n [-2, -1, 0, 1]\n [ 0, -2, -1, 0]]\n\n#### Useful special cases:\n\n tf.linalg.band_part(input, 0, -1) ==\u003e Upper triangular part.\n tf.linalg.band_part(input, -1, 0) ==\u003e Lower triangular part.\n tf.linalg.band_part(input, 0, 0) ==\u003e Diagonal.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `input` | A `Tensor`. Rank `k` tensor. |\n| `num_lower` | A `Tensor`. Must be one of the following types: `int32`, `int64`. 0-D tensor. Number of subdiagonals to keep. If negative, keep entire lower triangle. |\n| `num_upper` | A `Tensor`. Must have the same type as `num_lower`. 0-D tensor. Number of superdiagonals to keep. If negative, keep entire upper triangle. |\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 `input`. ||\n\n\u003cbr /\u003e"]]