How do I represent a PyTorch LSTM 3D Tensor?
As per the docs, I see that Pytorch’s LSTM expects all of its inputs to be 3D tensors. I am trying to do a simple sequence-to-sequence LSTM and I have:

class BaselineLSTM(nn.Module):
    def __init__(self):
        super(BaselineLSTM, self).__init__()

        self.lstm = nn.LSTM(input_size=100, hidden_size=100)

    def forward(self, x):
        print('x', x)
        x = self.lstm(x)

        return x


My x.size() is torch.Size([100, 1]). I expect I need a third dimension somehow, but I'm unsure as to what it actually means. Any help would be greatly appreciated. 

The input shape is further elaborated on in this Pytorch docs, in the Inputs: input, (h_0, c_0)section. The first dimension of the input tensor is expected to correspond to the sequence length, the second dimension the batch size, and the third, the input size.

So for your example, the input tensor x should actually be of size (seq_length, batch_size, 100).

Here is a detailed thread on the Pytorch forum for more details: https://discuss.pytorch.org/t/why-3d-input-tensors-in-lstm/4455/9
