espnet.nets.pytorch_backend.rnn.attentions.AttForward
Less than 1 minute
espnet.nets.pytorch_backend.rnn.attentions.AttForward
class espnet.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
Initializes internal Module state, shared by both nn.Module and ScriptModule.
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