How to test trained model on a new test set without loops

Let’s say I have a trained a model and loaded that by:

model = load_learner('saved_model.pkl')

and I have a separate test dataset passed to dataloaders

dls = Dataloaders(test_set, batch_size=256)

I want to sort of have something like:

pred, labels = model.get_preds(dls)

How can I do that?

1 Like

You should use the inference API, which really look something like this:

learn = load_learner('saved_model.pkl')
dl = learn.dls.test_dl(test_set, bs=256)
preds = learn.get_preds(dl=dl)