espnet.nets.pytorch_backend.rnn.attentions.AttCov
Less than 1 minute
espnet.nets.pytorch_backend.rnn.attentions.AttCov
class espnet.nets.pytorch_backend.rnn.attentions.AttCov(eprojs, dunits, att_dim, han_mode=False)
Bases: Module
Coverage mechanism attention
Reference: Get To The Point: Summarization with Pointer-Generator Network : (https://arxiv.org/abs/1704.04368)
- 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_list, scaling=2.0)
AttCov 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_list (list) – list of previous attention weight
- scaling (float) – scaling parameter before applying softmax
- Returns: attention weighted encoder state (B, D_enc)
- Return type: torch.Tensor
- Returns: list of previous attention weights
- Return type: list
reset()
reset states