paddlespeech.s2t.decoders.scorers.ctc 模块

CTC的ScorerInterface实现。

class paddlespeech.s2t.decoders.scorers.ctc.CTCPrefixScorer(ctc: Layer, eos: int)[来源]

基础: BatchPartialScorerInterface

CTCPrefixScore的解码器接口包装。

方法

batch_init_state(x)

获取解码的初始状态。

batch_score(ys, states, xs)

评分新的令牌批次(必需)。

batch_score_partial(y, ids, state, x)

为新令牌评分。

extend_prob(x)

扩展解码的概率。

extend_state(state)

用于解码的扩展状态。

final_score(state)

得分 eos(可选)。

init_state(x)

获取解码的初始状态。

score(y, state, x)

评分新令牌(必需)。

score_partial(y, ids, state, x)

评估新令牌的分数。

select_state(state, i[, new_id])

在主光束搜索中选择相对id的状态。

batch_init_state(x: Tensor)[来源]

获取解码的初始状态。

Args:

x (paddle.Tensor):编码后的特征张量

返回:初始状态

batch_score_partial(y, ids, state, x)[来源]

获得新令牌。

Args:

y (paddle.Tensor): 1D 前缀标记
ids (paddle.Tensor): paddle.int64 下一个标记的得分
state: 前缀标记的解码器状态
x (paddle.Tensor): 2D 编码器特征,用于生成 ys

Returns:
tuple[paddle.Tensor, Any]:

一个得分张量的元组,用于 y,其形状为 (len(next_tokens),) 和 ys 的下一个状态

extend_prob(x: Tensor)[来源]

扩展解码的概率。

此扩展用于流解码,如公式 (14) 所示,在 https://arxiv.org/abs/2006.14941

Args:

x (paddle.Tensor): 编码特征张量

extend_state(state)[来源]

扩展解码的状态。

此扩展用于流解码,如在https://arxiv.org/abs/2006.14941中的公式(14)所示

Args:

状态:超弦的状态

返回:扩展状态

init_state(x: Tensor)[来源]

获取解码的初始状态。

Args:

x (paddle.Tensor):编码后的特征张量

返回:初始状态

score_partial(y, ids, state, x)[来源]

获得新令牌。

Args:

y (paddle.Tensor):1D 前缀标记
next_tokens (paddle.Tensor):paddle.int64 下一个要评分的标记
state:前缀标记的解码器状态
x (paddle.Tensor):生成 ys 的 2D 编码特征

Returns:
tuple[paddle.Tensor, Any]:

y的得分张量的元组,形状为 (len(next_tokens),) 和 ys 的下一状态

select_state(state, i, new_id=None)[来源]

在主光束搜索中选择具有相对ID的状态。

Args:

状态: 解码器对于前缀标记的状态 i (int): 选择主束搜索中状态的索引 new_id (int): 如果有必要,选择状态的新标签id

Returns:

状态:修剪状态