How can I use WeightedRandomSampler with a Concatenated Dataset?

Hi all,
Edit: Resolved!
Because the data generation schemes differ for my samples depending on their class, I was going to create two different Dataset classes (one for each class) and then concatenate them to form my dataset (using However, my two classes have different numbers of samples and I’d like to sample from each relatively equally - I was figuring I could use WeightedRandomSampler to achieve this, but I can’t figure out how this works with a concatenated dataset. I have been looking at the source code/documentation but I’m having trouble figuring out generally how the sampling scheme works with a Dataloader and would love if someone could explain how this works in this (concanated dataset) case.
Thanks for any help

Hi…how to manage to use the weighted sampling when you used concat datasets .Can u please post ur solution ?