MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ctc_loss_dense

Function ctc_loss_dense

tensorflow/python/ops/ctc_ops.py:744–862  ·  view source on GitHub ↗

Computes 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 2006, P

(labels,
                   logits,
                   label_length,
                   logit_length,
                   logits_time_major=True,
                   unique=None,
                   blank_index=0,
                   name=None)

Source from the content-addressed store, hash-verified

742
743
744def ctc_loss_dense(labels,
745 logits,
746 label_length,
747 logit_length,
748 logits_time_major=True,
749 unique=None,
750 blank_index=0,
751 name=None):
752 """Computes CTC (Connectionist Temporal Classification) loss.
753
754 This op implements the CTC loss as presented in the article:
755
756 [A. Graves, S. Fernandez, F. Gomez, J. Schmidhuber.
757 Connectionist Temporal Classification: Labeling Unsegmented Sequence Data
758 with Recurrent Neural Networks. ICML 2006, Pittsburgh, USA,
759 pp. 369-376.](http://www.cs.toronto.edu/~graves/icml_2006.pdf)
760
761 Using the batched forward backward algorithm described in:
762
763 [Sim, K. C., Narayanan, A., Bagby, T., Sainath, T. N., & Bacchiani, M.
764 Improving the efficiency of forward-backward algorithm using batched
765 computation in TensorFlow.
766 Automatic Speech Recognition and Understanding Workshop (ASRU),
767 2017 IEEE (pp. 258-264).
768 ](https://ieeexplore.ieee.org/iel7/8260578/8268903/08268944.pdf)
769
770 Notes:
771 Significant differences from tf.compat.v1.nn.ctc_loss:
772 Supports GPU and TPU (tf.compat.v1.nn.ctc_loss supports CPU only):
773 For batched operations, GPU and TPU are significantly faster than using
774 ctc_loss on CPU.
775 This implementation runs on CPU, but significantly slower than ctc_loss.
776 Blank label is 0 rather num_classes - 1, unless overridden by blank_index.
777 Logits and labels are dense arrays with padding rather than SparseTensor.
778 The only mode supported is the same as:
779 preprocess_collapse_repeated=False, ctc_merge_repeated=True
780 To collapse labels, the caller can preprocess label sequence first.
781
782 The dense implementation supports both CPU, GPU and TPU. A fast path is
783 provided that significantly improves memory use for large vocabulary if the
784 caller preprocesses label sequences to get unique label indices on the CPU
785 (eg. in the data input pipeline) using ctc_ops.unique and simplies this in
786 the optional "unique" kwarg. This is especially useful for TPU and GPU but
787 also works with if used on CPU.
788
789 Args:
790 labels: tensor of shape [batch_size, max_label_seq_length]
791 logits: tensor of shape [frames, batch_size, num_labels], if
792 logits_time_major == False, shape is [batch_size, frames, num_labels].
793 label_length: tensor of shape [batch_size] Length of reference label
794 sequence in labels.
795 logit_length: tensor of shape [batch_size] Length of input sequence in
796 logits.
797 logits_time_major: (optional) If True (default), logits is shaped [time,
798 batch, logits]. If False, shape is [batch, time, logits]
799 unique: (optional) Unique label indices as computed by unique(labels). If
800 supplied, enable a faster, memory efficient implementation on TPU.
801 blank_index: (optional) Set the class index to use for the blank label.

Callers 1

ctc_loss_v2Function · 0.85

Calls 6

compute_ctc_lossFunction · 0.85
transposeMethod · 0.80
_get_dimFunction · 0.70
name_scopeMethod · 0.45
concatMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected