tf.sparse.slice
Stay organized with collections
Save and categorize content based on your preferences.
Slice a SparseTensor
based on the start
and size
.
tf.sparse.slice(
sp_input, start, size, name=None
)
Used in the notebooks
For example, if the input is
input_tensor = shape = [2, 7]
[ a d e ]
[b c ]
Graphically the output tensors are:
sparse.slice([0, 0], [2, 4]) = shape = [2, 4]
[ a ]
[b c ]
sparse.slice([0, 4], [2, 3]) = shape = [2, 3]
[ d e ]
[ ]
Args |
sp_input
|
The SparseTensor to split.
|
start
|
1-D. tensor represents the start of the slice.
|
size
|
1-D. tensor represents the size of the slice.
|
name
|
A name for the operation (optional).
|
Returns |
A SparseTensor objects resulting from splicing.
|
Raises |
TypeError
|
If sp_input is not a SparseTensor .
|
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.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.sparse.slice\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/sparse_ops.py#L1136-L1183) |\n\nSlice a `SparseTensor` based on the `start` and `size`.\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.sparse.slice`](https://www.tensorflow.org/api_docs/python/tf/sparse/slice), [`tf.compat.v1.sparse_slice`](https://www.tensorflow.org/api_docs/python/tf/sparse/slice)\n\n\u003cbr /\u003e\n\n tf.sparse.slice(\n sp_input, start, size, name=None\n )\n\n### Used in the notebooks\n\n| Used in the guide |\n|---------------------------------------------------------------------------------|\n| - [Working with sparse tensors](https://www.tensorflow.org/guide/sparse_tensor) |\n\nFor example, if the input is \n\n input_tensor = shape = [2, 7]\n [ a d e ]\n [b c ]\n\nGraphically the output tensors are: \n\n sparse.slice([0, 0], [2, 4]) = shape = [2, 4]\n [ a ]\n [b c ]\n\n sparse.slice([0, 4], [2, 3]) = shape = [2, 3]\n [ d e ]\n [ ]\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------|------------------------------------------------|\n| `sp_input` | The `SparseTensor` to split. |\n| `start` | 1-D. tensor represents the start of the slice. |\n| `size` | 1-D. tensor represents the size of the slice. |\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 `SparseTensor` objects resulting from splicing. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|----------------------------------------|\n| `TypeError` | If `sp_input` is not a `SparseTensor`. |\n\n\u003cbr /\u003e"]]