Stay organized with collections
Save and categorize content based on your preferences.
tensorflow::ops::MatrixBandPart
#include <array_ops.h>
Copy a tensor setting everything outside a central band in each innermost matrix to zero.
Summary
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:
- scope: A Scope object
- input: Rank
k
tensor.
- num_lower: 0-D tensor. Number of subdiagonals to keep. If negative, keep entire lower triangle.
- num_upper: 0-D tensor. Number of superdiagonals to keep. If negative, keep entire upper triangle.
Returns:
Output
: Rank k
tensor of the same shape as input. The extracted banded tensor.
Public attributes
Public functions
node
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
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 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tensorflow::ops::MatrixBandPart Class Reference\n\ntensorflow::ops::MatrixBandPart\n===============================\n\n`#include \u003carray_ops.h\u003e`\n\nCopy a tensor setting everything outside a central band in each innermost matrix to zero.\n\nSummary\n-------\n\nThe `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\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)) && (num_upper \u003c 0 || (n-m) \u003c= num_upper)`.\n\nFor example:\n\n\n```text\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\n\u003cbr /\u003e\n\n\n```scdoc\ntf.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\n\u003cbr /\u003e\n\n\n```scdoc\ntf.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\n\u003cbr /\u003e\n\nUseful special cases:\n\n\n```scdoc\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\n\u003cbr /\u003e\n\nArgs:\n\n- scope: A [Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- input: Rank `k` tensor.\n- num_lower: 0-D tensor. Number of subdiagonals to keep. If negative, keep entire lower triangle.\n- num_upper: 0-D tensor. Number of superdiagonals to keep. If negative, keep entire upper triangle.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.14/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): Rank `k` tensor of the same shape as input. The extracted banded tensor.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [MatrixBandPart](#classtensorflow_1_1ops_1_1_matrix_band_part_1aafbd4f5790f99aabe649a2603fab5026)`(const ::`[tensorflow::Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` num_lower, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` num_upper)` ||\n\n| ### Public attributes ||\n|----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [band](#classtensorflow_1_1ops_1_1_matrix_band_part_1a19ddd7640d84cfeb55298dcd2d150a8c) | `::`[tensorflow::Output](/versions/r2.14/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [operation](#classtensorflow_1_1ops_1_1_matrix_band_part_1a7f11fcb9cf1a97f13cded627a9579305) | [Operation](/versions/r2.14/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n\n| ### Public functions ||\n|----------------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_matrix_band_part_1a7a9ecf47b2def85ed1a8e7ab08dfe008)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_matrix_band_part_1a1b6a750bbd105a89c4ef9a398ccf7cf1)`() const ` | |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_matrix_band_part_1a2be19e72aeddcea40f0be7cc6d6fdf97)`() const ` | |\n\nPublic attributes\n-----------------\n\n### band\n\n```text\n::tensorflow::Output band\n``` \n\n### operation\n\n```text\nOperation operation\n``` \n\nPublic functions\n----------------\n\n### MatrixBandPart\n\n```gdscript\n MatrixBandPart(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n ::tensorflow::Input num_lower,\n ::tensorflow::Input num_upper\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n```"]]