espnet2.legacy.nets.pytorch_backend.rnn.attentions.AttForward
Less than 1 minute
espnet2.legacy.nets.pytorch_backend.rnn.attentions.AttForward
class espnet2.legacy.nets.pytorch_backend.rnn.attentions.AttForward(eprojs, dunits, att_dim, aconv_chans, aconv_filts)
Bases: Module
Forward attention module.
Reference: Forward attention in sequence-to-sequence acoustic modeling for speech synthesis
- Parameters:
- eprojs (int) β # projection-units of encoder
- dunits (int) β # units of decoder
- att_dim (int) β attention dimension
- aconv_chans (int) β # channels of attention convolution
- aconv_filts (int) β filter size of attention convolution
Initialize AttForward.
forward(enc_hs_pad, enc_hs_len, dec_z, att_prev, scaling=1.0, last_attended_idx=None, backward_window=1, forward_window=3)
Calculate AttForward forward propagation.
- 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) β attention weights of previous step
- scaling (float) β scaling parameter before applying softmax
- last_attended_idx (int) β index of the inputs of the last attended
- backward_window (int) β backward window size in attention constraint
- forward_window (int) β forward window size in attetion constraint
- 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.
