How can I validate on training dataloaders and get the same ordered item filename?

I am doing a medical image classification task, so I want to get the predict for each item (image) and the list of item filenames in the same order as the predicted results on my training set (also on valid and test set, but it is easy for them because valid and test set don’t shuffle items).

Because of some data augmentations in training dataset which we don’t want during inference, so in fastai v1, I can use


how can I do the same thing in fastai v2? Currently I fond nothing useful in forum and docs.

In short, my question is:

  1. How to validate on the training set using fastai v2?
  2. How can I output the item list of the training set and ensure that it is in the same order as the validation results on the training set? (Now I’ve come up with a silly way to rebuild a dataloader using the training items as a validation set, but I don’t think this is the best approach)

You could do something like this:

_,_,preds = learn.get_preds(dl=train_dl, with_decoded=True)
for index, item in enumerate(preds):
 prediction = list(dls.vocab[item])

you can simply do the following in Fastai 2:

Regards, Felix