udacity / deep-learning-v2-pytorch

Projects and exercises for the latest Deep Learning ND program https://www.udacity.com/course/deep-learning-nanodegree--nd101
MIT License
5.31k stars 5.33k forks source link

images Tensor needs to be moved to CPU (cifar10_cnn_exercise.ipynb) #270

Closed bfeeny closed 3 years ago

bfeeny commented 4 years ago

This has an error in the last part of the notebook Visualize Sample Test Results

If student has images Tensor on the GPU, then imshow(images[idx]) will fail with

TypeError: can't convert non-cpu tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

The solution notebook has it correct, it should be changed to imshow(images.cpu()[idx])

gargarchit commented 4 years ago

I just have a look and found that it is duplicate of #258 Also, a PR is already raised for this issue #226