espnet2.asr_transducer.decoder.stateless_decoder.StatelessDecoder
espnet2.asr_transducer.decoder.stateless_decoder.StatelessDecoder
class espnet2.asr_transducer.decoder.stateless_decoder.StatelessDecoder(vocab_size: int, embed_size: int = 256, embed_dropout_rate: float = 0.0, embed_pad: int = 0)
Bases: AbsDecoder
Stateless Transducer decoder module.
- Parameters:
- vocab_size – Output size.
- embed_size – Embedding size.
- embed_dropout_rate – Dropout rate for embedding layer.
- embed_pad – Embed/Blank symbol ID.
Construct a StatelessDecoder object.
batch_score(hyps: List[Hypothesis]) → Tuple[Tensor, None]
One-step forward hypotheses.
- Parameters:hyps – Hypotheses.
- Returns: Decoder output sequences. (B, D_dec) states: Decoder hidden states. None
- Return type: out
create_batch_states(new_states: List[Tensor | None]) → None
Create decoder hidden states.
- Parameters:new_states – Decoder hidden states. [N x None]
- Returns: Decoder hidden states. None
- Return type: states
forward(labels: Tensor, states: Any | None = None) → Tensor
Encode source label sequences.
- Parameters:
- labels – Label ID sequences. (B, L)
- states – Decoder hidden states. None
- Returns: Decoder output sequences. (B, U, D_emb)
- Return type: embed
init_state(batch_size: int) → None
Initialize decoder states.
- Parameters:batch_size – Batch size.
- Returns: Initial decoder hidden states. None
score(label_sequence: List[int], states: Any | None = None) → Tuple[Tensor, None]
One-step forward hypothesis.
- Parameters:
- label_sequence – Current label sequence.
- states – Decoder hidden states. None
- Returns: Decoder output sequence. (1, D_emb) state: Decoder hidden states. None
select_state(states: Tensor | None, idx: int) → None
Get specified ID state from decoder hidden states.
- Parameters:
- states – Decoder hidden states. None
- idx – State ID to extract.
- Returns: Decoder hidden state for given ID. None
set_device(device: device) → None
Set GPU device to use.
- Parameters:device – Device ID.