neuraltrain.metrics.metrics.CharacterErrorRates

class neuraltrain.metrics.metrics.CharacterErrorRates(blank_idx: int = 0)[source][source]

CTC greedy-decoded character error rate, returned in percent.

Wraps torchmetrics.text.CharErrorRate for a CTC head: greedy-decodes y_pred (collapse repeats + drop blanks), maps the integer label IDs to a private per-character alphabet via chr, and delegates the Levenshtein accumulation to the parent class.

Inputs

y_pred(B, T_out, n_classes)

Log-probs from a CTC head.

y_true(B, max_target_length)

Integer labels padded with blank_idx. Per-row label counts are recovered as (y_true != blank_idx).sum(-1).

compute() Tensor[source][source]

Calculate the character error rate.

update(y_pred: Tensor, y_true: Tensor) None[source][source]

Update state with predictions and targets.