# tf.keras.backend.ctc_decode

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/keras/backend/ctc_decode) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/keras/backend.py#L5635-L5681) |

Decodes the output of a softmax.

#### View aliases


**Compat aliases for migration**

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

[`tf.compat.v1.keras.backend.ctc_decode`](https://www.tensorflow.org/api_docs/python/tf/keras/backend/ctc_decode), \`tf.compat.v2.keras.backend.ctc_decode\`

<br />

    tf.keras.backend.ctc_decode(
        y_pred, input_length, greedy=True, beam_width=100, top_paths=1
    )

Can use either greedy search (also known as best path)
or a constrained dictionary search.

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `y_pred` | tensor `(samples, time_steps, num_categories)` containing the prediction, or output of the softmax. |
| `input_length` | tensor `(samples, )` containing the sequence length for each batch item in `y_pred`. |
| `greedy` | perform much faster best-path search if `true`. This does not use a dictionary. |
| `beam_width` | if `greedy` is `false`: a beam search decoder will be used with a beam of this width. |
| `top_paths` | if `greedy` is `false`, how many of the most probable paths will be returned. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `Tuple` | List: if `greedy` is `true`, returns a list of one element that contains the decoded sequence. If `false`, returns the `top_paths` most probable decoded sequences. Important: blank labels are returned as `-1`. Tensor `(top_paths, )` that contains the log probability of each decoded sequence. |

<br />