fn
ctc_loss_op
→TensorImplPtrint ctc_loss_op(const int & log_probs, const int & targets, const int & input_lengths, const int & target_lengths, int blank, bool zero_infinity)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).
Parameters
log_probsTensorImplPtrLog-probability tensor of shape
(T, N, C).targetsTensorImplPtrFlat
int32 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.blankintIndex of the CTC blank class.
zero_infinityboolWhen
true, infinite loss values (alignments with zero probability) are clamped to zero — both forward and backward.Returns
TensorImplPtrPer-sample loss tensor of shape (N,).