Not entirely sure about all cases, but I would have thought using a custom dataset/sampler would be quite common.
By the way the first link uses the first approach (just written in a slightly more generic form), I’ve copy pasted the relavent line here: dataset_sizes = {x: len(image_datasets[x]) for x in [‘train’, ‘val’]}
Is it possible to add a note or something on the tutorials/documentation to point out exceptions where the code won’t work? I feel like it would be extremely useful, seeing that this is an elusive bug to find,which can easily lead to misinterpreted stats.