I’m trying to use the function get_preds to get predictions on a test data set.
I’m running into some list index out of range error when I execute with this:
Anyone know how this works? I tried reading the source code - it seems to return a List object named res whose length is determined via a function call to “zip”. At this point I lose track of what zip does and running docs(zip) is not yielding any output.
Can someone help me out please! Thanks!
Try prefixing your line with
%debug to drop in to the debugger on exception (you’ll need to first press
c to continue) and then you can see what’s going on there.
My guess is that your test set is empty.
Yes indeed. Thank you!
I was able to review the test_ds length and determine the databunch wasn’t creating the test set correctly due to a test path error. Fixed now and able to see the predictions. On to running on a bigger test set and interpreting the predictions!
@nbharatula Would you mind sharing your code? Also, when you say interpreting predictions, do you simply mean comparing the predicted labels vs actual? Or, are you using the ClassificationInterpretation.from_learner() to plot confusion matrices and heatmaps on the test set? If so, I’m trying to do the same but by creating a test dataset using ImageList.from_folder.
ImageList (2 items)
Image (3, 299, 299),Image (3, 299, 299)
learned_model = load_learner(path, 'export_models.pkl', test=test)
preds,y = learned_model.get_preds(ds_type=DatasetType.Test)
tensor([[7.0309e-01, 3.0540e-02, 2.6613e-01, 2.3129e-04],
[5.3039e-02, 5.6551e-01, 3.5939e-03, 3.7785e-01]])
IndexError: index 0 is out of bounds for axis 0 with size 0
Any advice would be greatly appreciated. Thanks!