Dataloader from two Datasets

Hello everyone.
I have 2 datasets for a classification problem. Each has labels of different sizes. I want to sample from both at the same time for every iteration of training. I could do something like:
train_dl = DataLoader(trainset_1+trainset_2, shuffle = True, batch_size=128, num_workers=4)
But the issue is the mismatch in dimensions of labels and the data loader can’t stack tensors of different dimensions.
Is there any workaround for this?

Hello ! An easy workaround is to create two dataloaders, one for eatch dataset.

a, b = torch.ones(100,5,5), torch.zeros(100,4,4)
dla = torch.utils.data.DataLoader(a, batch_size=2)
dlb = torch.utils.data.DataLoader(b, batch_size=2)
for i,j in zip(dla,dlb):
    print(i,j)

Thanks a lot! This works. I was wondering if there is any way to do this with just one data loader.