Char Error Rate¶
Module Interface¶
- class torchmetrics.CharErrorRate(compute_on_step=None, **kwargs)[source]
Character Error Rate (CER) is a metric of the performance of an automatic speech recognition (ASR) system.
This value indicates the percentage of characters that were incorrectly predicted. The lower the value, the better the performance of the ASR system with a CharErrorRate of 0 being a perfect score. Character error rate can then be computed as:
- where:
is the number of substitutions,
is the number of deletions,
is the number of insertions,
is the number of correct characters,
is the number of characters in the reference (N=S+D+C).
Compute CharErrorRate score of transcribed segments against references.
- Parameters
- Returns
Character error rate score
Examples
>>> preds = ["this is the prediction", "there is an other sample"] >>> target = ["this is the reference", "there is another one"] >>> metric = CharErrorRate() >>> metric(preds, target) tensor(0.3415)
Initializes internal Module state, shared by both nn.Module and ScriptModule.
- compute()[source]
Calculate the character error rate.
- Return type
- Returns
Character error rate score
- update(preds, target)[source]
Store references/predictions for computing Character Error Rate scores.
Functional Interface¶
- torchmetrics.functional.char_error_rate(preds, target)[source]
character error rate is a common metric of the performance of an automatic speech recognition system. This value indicates the percentage of characters that were incorrectly predicted. The lower the value, the better the performance of the ASR system with a CER of 0 being a perfect score.
- Parameters
- Return type
- Returns
Character error rate score
Examples
>>> preds = ["this is the prediction", "there is an other sample"] >>> target = ["this is the reference", "there is another one"] >>> char_error_rate(preds=preds, target=target) tensor(0.3415)