tf.sparse.transpose
Stay organized with collections
Save and categorize content based on your preferences.
Transposes a SparseTensor
tf.sparse.transpose(
sp_input, perm=None, name=None
)
The returned tensor's dimension i will correspond to the input dimension
perm[i]
. If perm
is not given, it is set to (n-1...0), where n is
the rank of the input tensor. Hence by default, this operation performs a
regular matrix transpose on 2-D input Tensors.
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 [5, 4]
and
indices
/ values
:
[0, 2]: c
[1, 0]: a
[1, 3]: d
[3, 0]: b
Args |
sp_input
|
The input SparseTensor .
|
perm
|
A permutation of the dimensions of sp_input .
|
name
|
A name prefix for the returned tensors (optional)
|
Returns |
A transposed SparseTensor .
|
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.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.sparse.transpose\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/sparse/transpose) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/ops/sparse_ops.py#L2540-L2599) |\n\nTransposes a `SparseTensor`\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.transpose`](/api_docs/python/tf/sparse/transpose), [`tf.compat.v1.sparse_transpose`](/api_docs/python/tf/sparse/transpose)\n\n\u003cbr /\u003e\n\n tf.sparse.transpose(\n sp_input, perm=None, name=None\n )\n\nThe returned tensor's dimension i will correspond to the input dimension\n`perm[i]`. If `perm` is not given, it is set to (n-1...0), where n is\nthe rank of the input tensor. Hence by default, this operation performs a\nregular matrix transpose on 2-D input Tensors.\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 `[5, 4]` and\n`indices` / `values`: \n\n [0, 2]: c\n [1, 0]: a\n [1, 3]: d\n [3, 0]: b\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------|---------------------------------------------------|\n| `sp_input` | The input `SparseTensor`. |\n| `perm` | A permutation of the dimensions of `sp_input`. |\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 transposed `SparseTensor`. ||\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"]]