Loading data in custom dataloader based on condition

I have created my own CustomDataloader and in my getitem(self, idx) method, I want to make sure that the data is returned only if a certain condition is met. I want to know what should be returned from Dataloader in such cases?

def __getitem__(self, idx):

	if condition is True:
		...
		...
		...
		return Image, Label
	else
		...
		...
		do nothing

But we cannot return None. How can I handle this condition that my batch does not include this data, which may result in a smaller batch size?

1 Like

If you don’t use these data, why don’t you preprocess your training set before calling the dataloader ? You can do it with a for loop for instance.