loading data from the custom data loader in pytorch only if the data specifies a certain condition

You get that error because the dataloader has to return something. Here are three solutions:

  1. There is a libary called nonechucks which lets you create dataloaders in which you can skip samples.
  2. Usually you could preprocess/clean your data and kick the unwanted samples out.
  3. You could return some indicator that the sample is unwanted, for example
if "y":
    return data, target
else:
    return -1

And then you could check in your train loop if the “data” is -1 and skip the iteration. I hope this was helpful 🙂

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top