Berta_Biescas:

I want to enlarge my dataset and balance classes at the same time. I’m using random transforms to ensure new images at each batch and WeightedRandomSampler to try to balance the classes.
However, I don’t know how to check if classes are balance or not over the entire data set, since the sampler is acting over each batch. Does anyone have dealt with this problem?


I think the check you implemented should work (though using np.unique probably would be more efficient than handling each class with np.where). Where are you experiencing difficulties with it?
Best regards
Thomas
P.S.: If you enclose your code in triple backticks ``` , it’ll keep the formatting.