Hi,
I’m trying to figure out how should I implement loading data, where examples in one batch are depended on each other. The exactly idea is following:

Define the number of classes and classes per example per batch, Batch size is num_class x num_exp_per_class.
In each iteration take random classes (exactly num_class classes). Then for each class take num_exp_per_class examples

Currently all examples which I saw use “RandomSampler 12” or "SequentialSampler 11"
Both of this sampler are only shuffling the idxes, but I want sth more. My idea is following:

Write a sampler which will generate idxes using num_class and num_exp_per_class. So it will generate idxes for only one batch. For such operation is will only need labels.
Use DataLoaderIter to sample data, but use sampler function after each batch. (Theoretically I could use sampler to generate all idxes at once, but I’m planing to add sth like Hard-Negative Mining and then I will be better to selext idxes after each interations).

What do you think about this strategy?