espnet.nets.pytorch_backend.rnn.attentions.AttAdd
Less than 1 minute
espnet.nets.pytorch_backend.rnn.attentions.AttAdd
class espnet.nets.pytorch_backend.rnn.attentions.AttAdd(eprojs, dunits, att_dim, han_mode=False)
Bases: Module
Additive attention
- Parameters:
- eprojs (int) – # projection-units of encoder
- dunits (int) – # units of decoder
- att_dim (int) – attention dimension
- han_mode (bool) – flag to swith on mode of hierarchical attention and not store pre_compute_enc_h
Initializes internal Module state, shared by both nn.Module and ScriptModule.
forward(enc_hs_pad, enc_hs_len, dec_z, att_prev, scaling=2.0)
AttAdd forward
- Parameters:
- enc_hs_pad (torch.Tensor) – padded encoder hidden state (B x T_max x D_enc)
- enc_hs_len (list) – padded encoder hidden state length (B)
- dec_z (torch.Tensor) – decoder hidden state (B x D_dec)
- att_prev (torch.Tensor) – dummy (does not use)
- scaling (float) – scaling parameter before applying softmax
- Returns: attention weighted encoder state (B, D_enc)
- Return type: torch.Tensor
- Returns: previous attention weights (B x T_max)
- Return type: torch.Tensor
reset()
reset states