Skip to content
class

CtcLossBackward

CtcLossBackward

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:

L=−log⁡∑π∈B−1(y)∏t=1Tpπt(t) \mathcal{L} = -\log \sum_{\pi \in \mathcal{B}^{-1}(y)} \prod_{t=1}^{T} p_{\pi_t}^{(t)}

where B\mathcal{B} 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
Log-probability tensor of shape (T, N, C).
targetsTensorImplPtr
Flat int32 label tensor of shape (N * S,) where SS is the maximum target length.
input_lengthsTensorImplPtr
int32 vector of shape (N,) giving the valid time-step count per sample.
target_lengthsTensorImplPtr
int32 vector of shape (N,) giving the true label length per sample.
blankint
Index of the CTC blank class.
zero_infinitybool
When true, infinite loss values (alignments with zero probability) are clamped to zero — both forward and backward.

Instance methods

2
fn

release_own_saved

void release_own_saved()