Preprocess variable-length input by batch

Hi all,

I have an array contain inputs with different length. For example,

[
[[1, 1, 1], [2, 2, 2], [3, 3, 3]]
[[1, 1, 1]],
[[1, 1, 1], [2, 2, 2]]
....]

I am trying to apply zero-padding by batch that contains input of similar length. For instance, the input length may range from 1 to 30, I want to:

  • group 1–>10 then pad this group to length 10
  • group 11–>20 then pad this group to length 20
  • group 21–>30 then pad this group to length 30

After that, I want to load data of each group into the RNN (built by lstmcell).

Can anyone give me suggestion to preprocess and load the data?
Thank you in advance