How to handle variable sequence input data for conv1d (TCN) model? torch.nn.utils.rnn.pack_padded_sequence does not work for non-RNN based models

Input:
(Batch, T, L)

  • L stands for the length of features and L holds the same.
  • T stands for the length of the sequence and T changes from 2 to 60.

Currently, I am passing the padded inputs into the TCN model so that T is aligned with the max length 60.
However, there are many zeros in the such case as of T was 2 before padded.

I tried to use the function (torch.nn.utils.rnn.pack_padded_sequence) before passing the data into Conv1d models.
However, it didn’t work with the error:

TypeError: conv1d() received an invalid combination of arguments - got (PackedSequence, Tensor, Parameter, tuple, tuple, tuple, int), but expected one of:
 * (Tensor input, Tensor weight, Tensor bias, tuple of ints stride, tuple 
of ints padding, tuple of ints dilation, int groups)
      didn't match because some of the arguments have invalid types: (PackedSequence, Tensor, Parameter, tuple, tuple, tuple, int)
 * (Tensor input, Tensor weight, Tensor bias, tuple of ints stride, str padding, tuple of ints dilation, int groups)
      didn't match because some of the arguments have invalid types: (PackedSequence, Tensor, Parameter, tuple, tuple, tuple, int)

So how can I input variable length data in a batch to the Conv1D TCN model, meanwhile, remove all the padded zeros?

It would be much appreciated if you can give me some hints.