# tf.sparse.transpose

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/sparse/transpose) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/ops/sparse_ops.py#L2524-L2579) |

Transposes a `SparseTensor`

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.sparse.transpose`](https://www.tensorflow.org/api_docs/python/tf/sparse/transpose), [`tf.compat.v1.sparse_transpose`](https://www.tensorflow.org/api_docs/python/tf/sparse/transpose)

<br />

    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

<br />

<br />

<br />

| ## Args ||
|---|---|
| `sp_input` | The input `SparseTensor`. |
| `perm` | A permutation of the dimensions of `sp_input`. |
| `name` | A name prefix for the returned tensors (optional) |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A transposed `SparseTensor`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If `sp_input` is not a `SparseTensor`. |

<br />