How to only sample data from a dataloader with target == class

Is there a way to take a dataloader and only sample a batch of the predefined batch size, but only when the target is class N?

Based on the nature of what you’re trying to achieve - you might be able to apply a mask on the loaded train/test sets and create custom train/test sets that contain only required classes.

If this is a viable option for you, share some working code and I could assist as I’ve dealt with something similar to this previously.