How to change the way dataloader handles data?

Hi

I think for this it could be useful to implement a collate_fn function where you can define the concatenation of your data into a batch:

def collate_fn(samples):
    # samples is the list of samples returned from your
    # dataset, to be assembled into a batch
    # [[{a1},{a2}...{an}],[{b1},{b2}...{bn}]]
    return samples
    

dataloader = DataLoader(..., collate_fn=collate_fn)

Here are the PyTorch docs for this.

Hope this helps