@spro Thanks for sharing the code.
I noticed in your current implementation of Attn Class, all sentences in the same batch has the same length for attention scores(attn_energies variable in your code). e.g. a sentence of length 3 will have a attention score vector of length 20 if it is organized in the same batch with a 20 words long sentence. This should not be a problem for training the model. But I think it might be troublesome when visualizing the attentions, since the attention scores for a short sentence won’t add up to one. Maybe passing the input_lengths variable to Attn?
As you said it would be great if other layers(nn.Softmax in this case) had support for PackedSequence.