jackeown:

I think I could do this be using the hidden state output of the LSTM with hidden.repeat(length) , however it’s a little trickier with a batch of examples with different lengths, right?


The output will have the shape [seq_len, batch_size, num_directions*hidden_size], so you could use this instead of repeating the hidden tensor.



 jackeown:

What I’m wondering most about is things like language translation where the output is not length 1 and it is also not necessarily the length of the input. Do you know how you’d do that? Especially while still using batches?


These seq2seq models could be used with batched data either by e.g. using the rnn utility functions such as pad_sequence etc. You could also try to create batched data with the same length (or cut some words), but this might not work well for your use case and depends how variable the lengths in your dataset are.