How to create a batch for a few item indices

It seems I can create a single-item batch using the code below, is there a short cut? What if I want to make a batch with item idx [2, 10] (say those two had the worst loss and I want to focus on them)?

dls.after_batch(dls.before_batch(dls.after_item(dls.create_item(1))))

Thanks!

I put a dataloader creation code below, just in case you need a dls to test.

from fastai.vision.all import *
path = untar_data(URLs.PETS)
files = get_image_files(path/"images")
def label_func(f): return f[0].isupper()
dls = ImageDataLoaders.from_name_func(path, files, label_func, item_tfms=Resize(224))
1 Like