Hi, I am trying to plot the confusion metric but each time when I run a cell I am getting a different result.
Here is code:
pred_list=torch.zeros(0,dtype=torch.long, device=‘cpu’)
label_list=torch.zeros(0,dtype=torch.long, device=‘cpu’)
with torch.no_grad():
for inputs, labels in train_loader:
Hi. If I understand your problem correctly, you are getting a slightly different confusion matrix values each time you run the complete cell that makes the inference using your trained model.
If my understanding is correct, then one thing to try out in this case would be to set seed, something like this:
seed = 0
torch.manual_seed(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed_all(seed)
Yes, your understanding is correct. In each iteration when i run a complete cell confusion matrix values slightly updated. Let me try this solution which you shared with me.