tf.sparse.reorder
Stay organized with collections
Save and categorize content based on your preferences.
Reorders a SparseTensor
into the canonical, row-major ordering.
tf.sparse.reorder(
sp_input, name=None
)
Used in the notebooks
Note that by convention, all sparse ops preserve the canonical ordering
along increasing dimension number. The only time ordering can be violated
is during manual manipulation of the indices and values to add entries.
Reordering does not affect the shape of the SparseTensor
.
For example, if sp_input
has shape [4, 5]
and indices
/ values
:
[0, 3]: b
[0, 1]: a
[3, 1]: d
[2, 0]: c
then the output will be a SparseTensor
of shape [4, 5]
and
indices
/ values
:
[0, 1]: a
[0, 3]: b
[2, 0]: c
[3, 1]: d
Args |
sp_input
|
The input SparseTensor .
|
name
|
A name prefix for the returned tensors (optional)
|
Returns |
A SparseTensor with the same shape and non-empty values, but in
canonical ordering.
|
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.
[[["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.sparse.reorder\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#L821-L873) |\n\nReorders a `SparseTensor` into the canonical, row-major ordering.\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.reorder`](https://www.tensorflow.org/api_docs/python/tf/sparse/reorder), [`tf.compat.v1.sparse_reorder`](https://www.tensorflow.org/api_docs/python/tf/sparse/reorder)\n\n\u003cbr /\u003e\n\n tf.sparse.reorder(\n sp_input, name=None\n )\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| - [Client-efficient large-model federated learning via \\`federated_select\\` and sparse aggregation](https://www.tensorflow.org/federated/tutorials/sparse_federated_learning) |\n\nNote that by convention, all sparse ops preserve the canonical ordering\nalong increasing dimension number. The only time ordering can be violated\nis during manual manipulation of the indices and values to add entries.\n\nReordering does not affect the shape of the `SparseTensor`.\n\nFor example, if `sp_input` has shape `[4, 5]` and `indices` / `values`: \n\n [0, 3]: b\n [0, 1]: a\n [3, 1]: d\n [2, 0]: c\n\nthen the output will be a `SparseTensor` of shape `[4, 5]` and\n`indices` / `values`: \n\n [0, 1]: a\n [0, 3]: b\n [2, 0]: c\n [3, 1]: d\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------|---------------------------------------------------|\n| `sp_input` | The input `SparseTensor`. |\n| `name` | A name prefix for the returned tensors (optional) |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `SparseTensor` with the same shape and non-empty values, but in canonical ordering. ||\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"]]