espnet2.asr.decoder.rnn_decoder.RNNDecoder
espnet2.asr.decoder.rnn_decoder.RNNDecoder
class espnet2.asr.decoder.rnn_decoder.RNNDecoder(vocab_size: int, encoder_output_size: int, rnn_type: str = 'lstm', num_layers: int = 1, hidden_size: int = 320, sampling_probability: float = 0.0, dropout: float = 0.0, context_residual: bool = False, replace_sos: bool = False, num_encs: int = 1, att_conf: dict = {'aconv_chans': 10, 'aconv_filts': 100, 'adim': 320, 'aheads': 4, 'atype': 'location', 'awin': 5, 'han_conv_chans': -1, 'han_conv_filts': 100, 'han_dim': 320, 'han_heads': 4, 'han_mode': False, 'han_type': None, 'han_win': 5, 'num_att': 1, 'num_encs': 1})
Bases: AbsDecoder
Initializes internal Module state, shared by both nn.Module and ScriptModule.
forward(hs_pad, hlens, ys_in_pad, ys_in_lens, strm_idx=0)
Defines the computation performed at every call.
Should be overridden by all subclasses.
NOTE
Although the recipe for forward pass needs to be defined within this function, one should call the Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
init_state(x)
Get an initial state for decoding (optional).
- Parameters:x (torch.Tensor) – The encoded feature tensor
Returns: initial state
rnn_forward(ey, z_list, c_list, z_prev, c_prev)
score(yseq, state, x)
Score new token (required).
- Parameters:
- y (torch.Tensor) – 1D torch.int64 prefix tokens.
- state – Scorer state for prefix tokens
- x (torch.Tensor) – The encoder feature that generates ys.
- Returns: Tuple of : scores for next token that has a shape of (n_vocab) and next state for ys
- Return type: tuple[torch.Tensor, Any]
zero_state(hs_pad)