I did like you mentioned but I’m using the main dataset to making subsets for training and testing

Create PyTorch subsets from our subset-indices
test_set = Subset(our_dataset, indices=testset_inds)
training_set = Subset(our_dataset, indices=trainingset_inds)
then I use the DataLoader to stack samples
training_loader = DataLoader(training_set,  # we want to load our dataset
shuffle=True,  # shuffle for training
batch_size=4,  # stack 4 samples to a minibatch
num_workers=0  # no background workers
)
then when I check I got that error.
in default_collate
return torch.stack(batch, 0, out=out)
RuntimeError: stack expects each tensor to be equal size, but got [3615] at entry 0 and [3270] at entry 1