Getting predictions get_preds() for test sets



I have posted this on another part but perhaps it is too obvious but I can’t seem to find any answer to this trivial question.

If I run val_preds,val_targets = learn.get_preds() I get the predictions and targets for the validation set. How do I run it for the test set?

So far all the docs show learn.get_preds(is_test=True) but is_test has been changed to something else. Please advise !

Cheers, Hud

(ali baltschun) #2

i dont know for one liner

but its work fo me

preds = []
for i in range(0,30):
    p = learn.predict(data.test_ds.x[i])

(Sam Ariabod) #3

Hello, with v1 you can pass in the DatasetType to get_preds().

preds, y = learn.get_preds(DatasetType.Test)


Thanks this sort of worked, but now new problems arise.

I followed the solutions for vision in the inference tutorials and am able to predict different classes of boats from single images from the test set. However, images from a test_set folder returns only one class.

Have a look at the inference section in my gist-notebook

Has anyone had this problem?

(Erik Man) #5

I have the same problem. I’m just a beginner so I don’t know why, but my workaround is:

preds, y, losses = learn.get_preds(ds_type=DatasetType.Test, with_loss=True)
y = torch.argmax(preds, dim=1)