torchaudio.functional.rnnt_loss¶
- torchaudio.functional.rnnt_loss(logits: Tensor, targets: Tensor, logit_lengths: Tensor, target_lengths: Tensor, blank: int = -1, clamp: float = -1, reduction: str = 'mean', fused_log_softmax: bool = True)[source]¶
从使用循环神经网络进行序列转导 [Graves, 2012] 计算 RNN Transducer 损失。
RNN Transducer 损失通过定义所有长度的输出序列的分布,并联合建模输入输出和输出输出依赖关系来扩展 CTC 损失。
- 参数:
logits (Tensor) – 维度为 (batch, max seq length, max target length + 1, class) 的张量,包含来自 joiner 的输出
targets (Tensor) – 维度为 (batch, max target length) 的张量,包含零填充的目标
logit_lengths (Tensor) – 维度为 (batch) 的张量,包含来自编码器的每个序列的长度
target_lengths (Tensor) – 维度为 (batch) 的张量,包含每个序列的目标长度
blank (int, 可选) – 空白标签 (默认:
-1
)clamp (float, 可选) – 梯度裁剪值 (默认:
-1
)reduction (string, 可选) – 指定应用于输出的 reduction 类型:
"none"
|"mean"
|"sum"
。 (默认:"mean"
)fused_log_softmax (bool) – 如果在损失函数外部调用 log_softmax,则设置为 False (默认:
True
)
- 返回:
应用 reduction 选项后的损失。如果
reduction
为"none"
,则大小为 (batch),否则为标量。- 返回类型:
Tensor