Pytorch passing PackSequence argument to LSTM
As per my understanding, pack_sequence and pack_padded_sequence returns a PackedSequence, for which its data attribute should always be 1 dimension.

However, the following code gives the error:
RuntimeError: input must have 2 dimensions, got 1.

import torch
import torch.nn.utils.rnn as rnn_utils
a = torch.Tensor([1, 2, 3])
b = torch.Tensor([4, 5])
c = torch.Tensor([6])
seq = rnn_utils.pack_sequence([a, b, c])
lstm = torch.nn.LSTM(
    input_size=3,
    hidden_size=3
)
lstm(seq)


I've tried batch_first=True, that did not work.

The source file of error code: https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/rnn.py#L127

There are a few things wrong with your code. 


Input size should be 1
LSTM takes a vector at each time step, you are passing scalars and hence the dimension error. 


Below code should fix the problem. I made each input a (1,) size array and changed input size to 1. 

import torch 
import torch.nn.utils.rnn as rnn_utils 
a = torch.Tensor([[1], [2], [3]]) 
b = torch.Tensor([[4], [5]]) 
c = torch.Tensor([[6]]) 
seq = rnn_utils.pack_sequence([a, b, c]) 
lstm = torch.nn.LSTM(input_size=1, hidden_size=3) 
lstm(seq) 


The packed sequence can be multi-dimensional and it depends on the data at each time step. For example in this case seq will be 

PackedSequence(data=tensor([[1.],
        [4.],
        [6.],
        [2.],
        [5.],
        [3.]]), batch_sizes=tensor([3, 2, 1]))

