# tf.nn.ctc_unique_labels

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/ops/ctc_ops.py#L1269-L1302) |

Get unique labels and indices for batched labels for [`tf.nn.ctc_loss`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/nn/ctc_loss).

#### View aliases


**Compat aliases for migration**

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

[`tf.compat.v1.nn.ctc_unique_labels`](https://www.tensorflow.org/api_docs/python/tf/nn/ctc_unique_labels)

<br />

    tf.nn.ctc_unique_labels(
        labels, name=None
    )

For use with [`tf.nn.ctc_loss`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/nn/ctc_loss) optional argument `unique`: This op can be
used to preprocess labels in input pipeline to for better speed/memory use
computing the ctc loss on TPU.

<br />

<br />

<br />

| ## Example ||
|---|---|
| ctc_unique_labels(\[\[3, 4, 4, 3\]\]) -\> unique labels padded with 0: \[\[3, 4, 0, 0\]\] indices of original labels in unique: \[0, 1, 1, 0\] ||

<br />

<br />

<br />

<br />

| ## Args ||
|---|---|
| `labels` | tensor of shape \[batch_size, max_label_length\] padded with 0. |
| `name` | A name for this `Op`. Defaults to "ctc_unique_labels". |

<br />

<br />

<br />

| ## Returns ||
|---|---|
| tuple of <br /> - unique labels, tensor of shape `[batch_size, max_label_length]` - indices into unique labels, shape `[batch_size, max_label_length]` ||

<br />