Variable Length Data Audio

@ptrblck_de I have a variable length data and I want to first sort the data then select the batch sizes from that. (Data Loader). Any Suggestions Please

U should write a custom collate_fn and sort the data inside it, below is an example:

def collate_fn(batch):
    inp, labels = zip(*batch)
    inp = SORTED_VERSION
    return pad_sequence(inp), tc.stack(labels)

(I assume each index from ur dataset returns a tuple with 2 tensors)

Another example here. Search pad_data func

Thank you, but I think bucketing will work here otherwise I wont be able to shuffle the dataset. Do you have any link/suggestion @G.M

Maybe this helps? https://pytorch.org/text/data.html#bucketiterator