LSTM, what exactly defines the batch size?

Hello everybody,
I’m pretty new to Pytorch. I have two questions, hope you can help me.
Imagine the following sequence:

input = [[1,2,3,4,5,6,7,8,9,10]]

Let’s say I want to learn this sequence using 2 look backs. So I would have:

input = [[1,2], [2,3], [3,4]....] and so on.

So my first question is, how do I have pass the input to a LSTM? I know I could shape the input like (seq_len, batch_size, features) so here it would be (2, 9, 1), right?

Does the following has the same meaning? So i loop over the batches and pass them to the LSTM but with batch_size=1. After all batches I do the backward()?

for i in range(input.size(0)):
    x = [input[i].view(2,1,1)

Is there a difference of setting the batch_size parameter or just looping over the batches?

  1. Let’s say I want to predict a value out of 4 look backs. And I have 200 samples of these sequences. How do I have to build the input vector now? Does the number of training samples acutally stands for the batch_size?

Thank you!

I have a same question about the batch_size and sequence length in Pytorch, so is there anybody to answer the question?