When used pack_padded_sequence for the above names the output generated is
J G N e r a m i i a f f l f e d i h i t n h o s v
which is clearly not in the order in which it were sent because of their varying lengths.
The question is, in what order should I arrange the true outputs so that they are compared to their corresponding predicted output for the computation of loss.
short answer:
before using pack_padded_sequence you need to sort the inputs by length and pass that to the function.
sorting will return the permutation index and you can use that to permute your output
longer answer:
when using packed sequence the strings are rearranged by length
then they are stacked vertically
in your example it will be
Jemaldinov
Griffiths
Naifeh
each iteration it will process the i’th column across all rows if exists and pass it to the next rnn cell
that’s why it seems to you like the letters got scrambled.