Custom Sampler for Omniglot

I’m trying to create a Siamese network for the Omniglot dataset, for which I need to implement a custom sampler that will yield batches of pairs of images on which the neural net will be run. I need a little help with building this custom sampler. A little guidance in the right direction should be enough I believe.

The usual approach would be to write a custom Dataset and load and return the image pairs in the __geitem__ method of it.
How would you like to create these pairs, i.e. do you have any specific logic in mind?
Also, have a look at the Data Loading tutorial for more information on how to create a Dataset.

Hey!

Yeah so basically I have to just generate random pairs of images and if they are same I label the output as 1, otherwise I label it as 0. My only concern is I want each batch to have the same number of different pairs as there are same pairs of images, because of which I was hoping to create a Sampler that can generate these batches for me, which I can then use to initialize the DataLoader class.