sooftware/conformer

RuntimeError: input must have 2 dimensions, got 1

mjurkus opened this issue · 1 comments

Hi,

I'm trying to use this model, but I'm having issues.
I'm using PyTorch 1.8.0 and Pytorch Lightning.

At first, I got an error:

RuntimeError: `lengths` array must be sorted in decreasing order when `enforce_sorted` is True. You can pass `enforce_sorted=False` to pack_padded_sequence and/or pack_sequence to sidestep this requirement if you do not need ONNX exportability.

that I fixed by updating DecoderRNNT and setting enforce_sorted=False

embedded = nn.utils.rnn.pack_padded_sequence(embedded.transpose(0, 1), input_lengths.cpu(), enforce_sorted=False)

but then I got an error at the bottom. Not sure what could be wrong?

According to docs provided the inputs should be:

 inputs (torch.LongTensor): A target sequence passed to decoder. `IntTensor` of size ``(batch, seq_length)``

And they are - torch.Size([32, 320])

The error:

 File "torch_asr/asr/models/conformer/model.py", line 169, in forward
    decoder_outputs, _ = self.decoder(targets, target_lengths)
  File "/home/martynas/.cache/pypoetry/virtualenvs/torch-asr-9y4FJ-MW-py3.7/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "torch_asr/asr/models/conformer/decoder.py", line 122, in forward
    outputs, hidden_states = self.rnn(embedded, hidden_states)
  File "/home/martynas/.cache/pypoetry/virtualenvs/torch-asr-9y4FJ-MW-py3.7/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/martynas/.cache/pypoetry/virtualenvs/torch-asr-9y4FJ-MW-py3.7/lib/python3.7/site-packages/torch/nn/modules/rnn.py", line 659, in forward
    self.check_forward_args(input, hx, batch_sizes)
  File "/home/martynas/.cache/pypoetry/virtualenvs/torch-asr-9y4FJ-MW-py3.7/lib/python3.7/site-packages/torch/nn/modules/rnn.py", line 605, in check_forward_args
    self.check_input(input, batch_sizes)
  File "/home/martynas/.cache/pypoetry/virtualenvs/torch-asr-9y4FJ-MW-py3.7/lib/python3.7/site-packages/torch/nn/modules/rnn.py", line 200, in check_input
    expected_input_dim, input.dim()))
RuntimeError: input must have 2 dimensions, got 1

That was an error on my part - mixed up inputs.