How to get data with the highest confidence

I want to get the images from the training set/validation with the highest confidence by the model


You have to sort by losses from validation run.

dl = learn.dls.valid # or learn.dls.train 
inputs, preds, targs, losses = learn.get_preds(dl=dl, with_input=True, with_loss=True)
sorted, indices = torch.sort(losses) # first item will have the lowest loss (so is the most confident)
inputs[indices] # items sorted from lowset to highest loss
1 Like