Kaixhin/grokking-pytorch

Python has stoped working

rezaizanloo opened this issue · 1 comments

This line of my code
correct += (predicted[0] == labels[0]).sum().item()
cause Python has stoped working.

6. Calculate Accuracy

correct = 0
total = 0
with torch.no_grad():
for data in testloader:
images, labels = data
outputs = net(images)
_,predicted = torch.max(outputs.data,1)
total +=labels.size(0)

When my code reach to this line, the widows kill the python kernel.
image

print('Accuracy of the Network is : %d' %(100*correct/total))

I've checked my code, which runs fine, as well as the code which you've displayed here which is different, but this also runs fine for me. This shouldn't have anything to do with the code I've provided, so please post your issue on the PyTorch forums for help on resolving this.