How to get Output without Softmax


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):
    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 = torch.tensor(np.concatenate(preds))
        labels = torch.tensor(np.concatenate(labels))

        return(preds, labels)
1 Like

thank you it worked:)