Thanks for the reply! As mentioned above, I got 64*20*1024 (i.e., data) for result and 64 (i.e., lens) for a variable that contains lengths (all <= 20 in my case). When I did data[:, lens - 1], I got a variable of 64*64*1024. Was I doing something bad?