Computes the CTC (Connectionist Temporal Classification) Loss. This op implements the CTC loss as presented in the article: [A. Graves, S. Fernandez, F. Gomez, J. Schmidhuber. Connectionist Temporal Classification: Labeling Unsegmented Sequence Data with Recurrent Neural Networks. ICML 200
(labels,
inputs=None,
sequence_length=None,
preprocess_collapse_repeated=False,
ctc_merge_repeated=True,
ignore_longer_outputs_than_inputs=False,
time_major=True,
logits=None)
| 47 | # pylint: disable=protected-access, invalid-name |
| 48 | @tf_export(v1=["nn.ctc_loss"]) |
| 49 | def ctc_loss(labels, |
| 50 | inputs=None, |
| 51 | sequence_length=None, |
| 52 | preprocess_collapse_repeated=False, |
| 53 | ctc_merge_repeated=True, |
| 54 | ignore_longer_outputs_than_inputs=False, |
| 55 | time_major=True, |
| 56 | logits=None): |
| 57 | """Computes the CTC (Connectionist Temporal Classification) Loss. |
| 58 | |
| 59 | This op implements the CTC loss as presented in the article: |
| 60 | |
| 61 | [A. Graves, S. Fernandez, F. Gomez, J. Schmidhuber. |
| 62 | Connectionist Temporal Classification: Labeling Unsegmented Sequence Data |
| 63 | with Recurrent Neural Networks. ICML 2006, Pittsburgh, USA, |
| 64 | pp. 369-376.](http://www.cs.toronto.edu/~graves/icml_2006.pdf) |
| 65 | |
| 66 | Input requirements: |
| 67 | |
| 68 | ``` |
| 69 | sequence_length(b) <= time for all b |
| 70 | |
| 71 | max(labels.indices(labels.indices[:, 1] == b, 2)) |
| 72 | <= sequence_length(b) for all b. |
| 73 | ``` |
| 74 | |
| 75 | Notes: |
| 76 | |
| 77 | This class performs the softmax operation for you, so inputs should |
| 78 | be e.g. linear projections of outputs by an LSTM. |
| 79 | |
| 80 | The `inputs` Tensor's innermost dimension size, `num_classes`, represents |
| 81 | `num_labels + 1` classes, where num_labels is the number of true labels, and |
| 82 | the largest value `(num_classes - 1)` is reserved for the blank label. |
| 83 | |
| 84 | For example, for a vocabulary containing 3 labels `[a, b, c]`, |
| 85 | `num_classes = 4` and the labels indexing is `{a: 0, b: 1, c: 2, blank: 3}`. |
| 86 | |
| 87 | Regarding the arguments `preprocess_collapse_repeated` and |
| 88 | `ctc_merge_repeated`: |
| 89 | |
| 90 | If `preprocess_collapse_repeated` is True, then a preprocessing step runs |
| 91 | before loss calculation, wherein repeated labels passed to the loss |
| 92 | are merged into single labels. This is useful if the training labels come |
| 93 | from, e.g., forced alignments and therefore have unnecessary repetitions. |
| 94 | |
| 95 | If `ctc_merge_repeated` is set False, then deep within the CTC calculation, |
| 96 | repeated non-blank labels will not be merged and are interpreted |
| 97 | as individual labels. This is a simplified (non-standard) version of CTC. |
| 98 | |
| 99 | Here is a table of the (roughly) expected first order behavior: |
| 100 | |
| 101 | * `preprocess_collapse_repeated=False`, `ctc_merge_repeated=True` |
| 102 | |
| 103 | Classical CTC behavior: Outputs true repeated classes with blanks in |
| 104 | between, and can also output repeated classes with no blanks in |
| 105 | between that need to be collapsed by the decoder. |
| 106 |
nothing calls this directly
no test coverage detected