I am using following function to predict and eventually plotting confusion matrix. Here I am using CroosEntropyLoss criterion. The model is returning to values, which are tuples, So when I m using this function after saving the training model. It throws the typeError :exp(): argument ‘input’ (position 1) must be Tensor, not tuple. In bold line. What I am grasping is in exp function i need a scaler number and this a tuple, I took the max value of tuple using max() method , but still its giving same error.
Please suggest a solution
def predict_sm(model=None, dataloader=None, device=None, path=None):
if path:
model.load_state_dict(torch.load(path))
model.eval()
model.to(device)
y_pred = []
for X, y,y1 in dataloader:
X = X.to(device)
with torch.no_grad():
logProb,_ = model(X)
**Prob = torch.exp(logProb)**
Pred = torch.argmax(Prob, dim=1).long()
y_pred.append(list(Pred.detach().cpu().numpy()))
print(sum(y_pred,[]))
return sum(y_pred,[])