快捷方式

torcheval.metrics.WordInformationLost

class torcheval.metrics.WordInformationLost(device: device | None = None)

单词信息丢失 (WIL) 是自动语音识别系统性能的一个指标。该值表示在一组真实句子和一组假设句子之间错误预测的单词的百分比。值越低,ASR 系统的性能越好,WordInformationLost 为 0 表示完美得分。单词信息丢失率可以计算如下:

\[wil = 1 - \frac{C}{N} * \frac{C}{P}\]
其中
  • \(C\) 是正确单词的数量,

  • \(N\) 是参考中的单词数量

  • \(P\) 是预测中的单词数量

其函数版本为 torcheval.metrics.functional.word_information_lost()

示例

>>> from torcheval.metrics.text import WordInformationLost
>>> preds = ["this is the prediction", "there is an other sample"]
>>> target = ["this is the reference", "there is another one"]
>>> metric = WordInformationLost()
>>> metric(preds, target)
tensor(0.6528)
__init__(device: device | None = None) None

初始化一个指标对象及其内部状态。

使用 self._add_state() 初始化指标类的状态变量。状态变量应为 torch.Tensortorch.Tensor 列表、以 torch.Tensor 作为值的字典或 torch.Tensor 的 deque。

方法

__init__([device])

初始化一个指标对象及其内部状态。

计算()

计算单词信息丢失。

load_state_dict(state_dict[, strict])

从 state_dict 加载指标状态变量。

merge_state(metrics)

将指标状态与来自其他指标实例的对应状态合并。

重置()

将指标状态变量重置为其默认值。

state_dict()

在 state_dict 中保存指标状态变量。

to(device, *args, **kwargs)

将指标状态变量中的张量移动到设备。

update(input, target)

存储用于计算单词信息丢失分数的预测/参考。

属性

设备

Metric.to() 的最后一个输入设备。

文档

获取 PyTorch 的全面开发者文档

查看文档

教程

获取初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并获得问题的解答

查看资源