快速連結

RNNTBeamSearch

class torchaudio.models.RNNTBeamSearch(model: RNNT, blank: int, temperature: float = 1.0, hypo_sort_key: Optional[Callable[[Tuple[List[int], Tensor, List[List[Tensor]], float]] = None, step_max_tokens: int = 100)[source]

RNN-T 模型的 Beam search 解碼器。

另請參閱

參數:
  • model (RNNT) – 要使用的 RNN-T 模型。

  • blank (int) – 詞彙表中空白符號的索引。

  • temperature (float, optional) – 應用於聯合網路輸出的溫度。較大的值會產生更均勻的樣本。(預設值:1.0)

  • hypo_sort_key (Callable[[Hypothesis], float] or None, optional) – 可呼叫物件,用於計算給定假設的分數,以對假設進行排名。如果為 None,則預設為可呼叫物件,該物件返回按符號序列長度正規化的假設分數。(預設值:None)

  • step_max_tokens (int, optional) – 每個輸入時間步要發出的最大符號數。(預設值:100)

使用 RNNTBeamSearch 的教學
Online ASR with Emformer RNN-T

使用 Emformer RNN-T 進行線上 ASR

使用 Emformer RNN-T 進行線上 ASR
Device AV-ASR with Emformer RNN-T

使用 Emformer RNN-T 進行裝置端 AV-ASR

使用 Emformer RNN-T 進行裝置端 AV-ASR

方法

forward

RNNTBeamSearch.forward(input: Tensor, length: Tensor, beam_width: int) List[Tuple[List[int], Tensor, List[List[Tensor]], float]][source]

為給定的輸入序列執行 beam search。

T:幀數;D:每幀的特徵維度。

參數:
  • input (torch.Tensor) – 輸入幀序列,形狀為 (T, D) 或 (1, T, D)。

  • length (torch.Tensor) – 輸入序列中有效幀的數量,形狀為 () 或 (1,)。

  • beam_width (int) – 搜尋期間要使用的 beam 大小。

回傳:

beam search 找到的前 beam_width 個假設。

回傳類型:

List[Hypothesis]

infer

RNNTBeamSearch.infer(input: Tensor, length: Tensor, beam_width: int, state: Optional[List[List[Tensor]]] = None, hypothesis: Optional[List[Tuple[List[int], Tensor, List[List[Tensor]], float]]] = None) Tuple[List[Tuple[List[int], Tensor, List[List[Tensor]], float]], List[List[Tensor]]][source]

在串流模式下,為給定的輸入序列執行 beam search。

T:幀數;D:每幀的特徵維度。

參數:
  • input (torch.Tensor) – 輸入幀序列,形狀為 (T, D) 或 (1, T, D)。

  • length (torch.Tensor) – 輸入序列中有效幀的數量,形狀為 () 或 (1,)。

  • beam_width (int) – 搜尋期間要使用的 beam 大小。

  • state (List[List[torch.Tensor]] or None, optional) – 表示前一次調用中產生的轉錄網路內部狀態的張量列表的列表。(預設值:None

  • hypothesis (List[Hypothesis] or None) – 來自前一次調用的假設,用於為搜尋提供種子。(預設值:None

回傳:

List[Hypothesis]

beam search 找到的前 beam_width 個假設。

List[List[torch.Tensor]]

表示目前調用中產生的轉錄網路內部狀態的張量列表的列表。

回傳類型:

(List[Hypothesis], List[List[torch.Tensor]])

支援結構

假設 (Hypothesis)

torchaudio.models.Hypothesis

由 RNN-T beam search 解碼器產生的假設,表示為 (符號, 預測網路輸出, 預測網路狀態, 分數) 的 tuple。

別名為 Tuple[List[int], Tensor, List[List[Tensor]], float]


© 版權所有 2024,Torchaudio 貢獻者。

使用 Sphinx 建置,主題由 Read the Docs 提供。

文件

存取 PyTorch 的完整開發者文件

查看文件

教學

取得為初學者和進階開發者提供的深入教學

查看教學

資源

尋找開發資源並獲得解答

查看資源