Python wrappers
Public Python APIs implemented by this engine symbol.Connectionist Temporal Classification (CTC) loss.
Computes the negative log-probability of all valid alignments between an input log-probability sequence and a flat target label sequence using the forward algorithm (Graves et al., 2006). The blank symbol allows the model to emit "no character" at any time step, and the loss is summed over all valid label expansions:
where is the standard CTC collapse operation. No reduction
is applied here — the caller is expected to apply mean / sum in
Python.
References
Graves et al., "Connectionist Temporal Classification: Labelling
Unsegmented Sequence Data with Recurrent Neural Networks" (ICML 2006).
Autograd node for the CTC loss — one per-sample loss per batch entry,
differentiable in log_probs only (targets and lengths are integers).
The backward reruns the alpha / beta recursion rather than keeping the
forward's lattices, which are per-sample and as large as T * (2S + 1).
Like the reference framework, it is differentiable once:
create_graph=True through it raises.
Parameters
log_ probsTensorImplPtr(T, N, C).targetsTensorImplPtrint32 label tensor of shape (N * S,) where is the maximum target length.input_ lengthsTensorImplPtrint32 vector of shape (N,) giving the valid time-step count per sample.target_ lengthsTensorImplPtrint32 vector of shape (N,) giving the true label length per sample.blankintzero_ infinitybooltrue, infinite loss values (alignments with zero probability) are clamped to zero — both forward and backward.