I’ve collected the pictures, exported them, unzipped them, and I ran the script in the Jupyter Notebook
The script mostly worked. I saw the importing of the pytorch alexnet happen, but then, towards the end of the script, I got this error…
(I copied the script over and named it train1.py)
Traceback (most recent call last): File "train1.py", line 44, in <module> images = images.to(device) NameError: name 'device' is not defined
Obviously the error originates in this section…
test_error_count = 0.0 for images, labels in iter(test_loader): images = images.to(device) labels = labels.to(device) outputs = model(images) test_error_count += float(torch.sum(torch.abs(labels - outputs.argmax(1))))
I’m doing the best I can, however I’m not that good at programming, but it would seem to me that the error has something to do with the (device) variable not being defined. I’ve tried a few things, but I can’t seem to figure out where I’ve gone wrong in copying over the script from the Jupyter Notebook
I must have missed something. Can somebody please help me ?