I am doing something wrong trying to append the results from the models prediction.
My attempt is to append the predictions to a new variable and the convert that variable with the over 40,000 outcomes to array to save into CSV.
My attempt is as follows:
totalpreds = []
import seaborn as sns
nb_classes = 2
confusion_matrix = torch.zeros(nb_classes, nb_classes)
with torch.no_grad():
for i, (inputs, classes) in enumerate(testloader):
inputs = inputs
classes = classes
outputs = clf(inputs)
_, preds = torch.max(outputs, 1)
# Saving predictions
arr = preds.cpu().numpy()
totalpreds.append(arr)
# write CSV
np.savetxt('output.csv', totalpreds)
It’s not working… I am sure it’s something wrong in my thinking here. Any help would be appreciated!