rnn = nn.LSTM(10, 20, 2)
input = Variable(torch.randn(5, 3, 10))
h0 = Variable(torch.randn(2, 3, 20))
c0 = Variable(torch.randn(2, 3, 20))
output, hn = rnn(input, (h0, c0))



input (seq_len, batch, input_size)
output (seq_len, batch, hidden_size * num_directions): tensor containing the output features (h_t) from the last layer of the RNN, for each t.
I don’t know of anyway to do this using the sequential module
And yes I’m suggesting loop on:
Output, (hx, cx) = model(input, (hx,cx))
I’m walking my dog right now and using phone for this but can provide actual code example later if you need when with computer