Realm

oa::ml::loss::ctc

Compute the mean connectionist temporal classification loss over a batch. log_probs has shape [T, N, C] and holds log-probabilities over C classes including the blank class. targets has shape [N, S] and holds the label sequences, input_lengths and target_lengths have shape [N] and hold each item’s frame and label counts. blank is the blank class index and must be below C. The returned matrix is an FP32 scalar: the mean of the per-item negative log-likelihoods. Label entries shorter than S and frames beyond an item’s input_lengths entry are ignored. Target classes outside 0..C produce a NaN item loss without an out-of-bounds read, matching the cross-entropy invalid-target contract. Errors Returns an error when ranks, shapes, dtypes, blank, target_lengths width, ownership, allocation, or runtime recording are invalid.

FnRust public API

Function Documentation

pub fn ctc( log_probs: &Matrix, targets: &Matrix, input_lengths: &Matrix, target_lengths: &Matrix, blank: usize ) -> Result<Matrix>
Compute the mean connectionist temporal classification loss over a batch. log_probs has shape [T, N, C] and holds log-probabilities over C classes including the blank class. targets has shape [N, S] and holds the label sequences, input_lengths and target_lengths have shape [N] and hold each item’s frame and label counts. blank is the blank class index and must be below C. The returned matrix is an FP32 scalar: the mean of the per-item negative log-likelihoods. Label entries shorter than S and frames beyond an item’s input_lengths entry are ignored. Target classes outside 0..C produce a NaN item loss without an out-of-bounds read, matching the cross-entropy invalid-target contract. Errors Returns an error when ranks, shapes, dtypes, blank, target_lengths width, ownership, allocation, or runtime recording are invalid.