Pytorch GRU model: invalid argument 2: dimension 1 out of range of 1D tensor

Hi there,

I’ve been trying to run the hierarchical attention GRU model from this link: https://github.com/EdGENetworks/attention-networks-for-classification

And this excerpted line of code produces the following error:

sent_attn_model.sent_gru(s, state_sent)

RuntimeError: invalid argument 2: dimension 1 out of range of 1D tensor at /Users/soumith/miniconda2/conda-bld/pytorch_1503975723910/work/torch/lib/TH/generic/THTensor.c:24

I guess this has to do with the size of the input and I’m currently trying to debug the error? But the error message got me confused, as I don’t have any 1D tensor as input? Hopefully, someone with more experience can kindly provide some pointers?

Here s is a float tensor, of size 5400*40.

Variable containing:
1.4417e-01 4.8281e-02 -2.9375e-01 … 1.9444e-01 -3.1914e-01 1.8645e-01
2.9694e-02 4.5594e-02 -2.4379e-01 … 1.3730e-01 -8.2444e-02 2.0483e-01
1.0212e-03 -7.9410e-02 -2.9818e-01 … 1.9834e-01 -2.5931e-01 2.3803e-01
… ⋱ …
1.2643e-01 3.4199e-02 -3.1882e-01 … 1.3287e-01 -1.8154e-02 2.3123e-01
-2.8375e-02 -2.6537e-01 -2.2694e-01 … 1.5493e-01 -1.0618e-01 2.8114e-01
7.7176e-02 4.3325e-02 -2.7065e-01 … 5.9863e-02 1.0924e-01 2.0411e-01
[torch.FloatTensor of size 5400x40]

And state_sent is a [torch.FloatTensor of size 2x10x20] used to store the bi-directional hidden vector. 10 is the batch size, and 20 is the hidden state size.

Thanks!!