Hi,
I am trying to get output for each images in my test data but i dont want softmax to be applied since there are unknown classes in the test data. I couldn’t figure out how to do
thank you
Hi,
I am trying to get output for each images in my test data but i dont want softmax to be applied since there are unknown classes in the test data. I couldn’t figure out how to do
thank you
Something like this.
def get_raw_preds(learner: Learner, ds_type:DatasetType=DatasetType.Valid):
learner.model.eval()
dl = learner.dl(ds_type)
with torch.no_grad():
labels = []
preds = []
for x, label in dl:
pred = learner.model(x)
label_cpu = label.cpu().detach().numpy()
pred_cpu = pred.cpu().detach().numpy()
preds.append(pred_cpu)
labels.append(label_cpu)
preds = torch.tensor(np.concatenate(preds))
labels = torch.tensor(np.concatenate(labels))
return(preds, labels)
thank you it worked:)