Have two generators produce the same indices

How can I create two data loaders that sample from two datasets in the same order?

That is, I want to create Dataloader1 that samples from dataset1 in some order (returns indices 1, 3, 4, 6, 7 for example) and Dataloader2 that samples from dataset2 in the same order.

Please let me know if I can add more clarity.

If you pass in a deterministic sampler into both DataLoader, (or make the two samplers share the same initial seed), the output order should match between the two.

1 Like