yunjey / pytorch-tutorial

PyTorch Tutorial for Deep Learning Researchers
MIT License
29.54k stars 8k forks source link

RuntimeError in Logistic Regression python file #220

Open htlee6 opened 3 years ago

htlee6 commented 3 years ago

Hi Yunjey,

I'm on macOS 10.15.7, torch v1.6.0 and Python v3.8.5 In the current tutorials/01-basics/logistic_regression/main.py, at line 73, it wrotes:

    print('Accuracy of the model on the 10000 test images: {} %'.format(100 * correct / total))

However, this snippet of code is out of fashion because the interpreter throws a RuntimeError as detailed:

Traceback (most recent call last):
  File "/home/lihaotian/IdeaSync/PyCharm/aidl/hw3/github.py", line 73, in <module>
    print('Accuracy of the model on the 10000 test images: {} %'.format(100 * correct / total))
RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future release div will perform true division as in Python 3. Use true_divide or floor_divide (// in Python) instead.

Process finished with exit code 1

I will fix this bug soon.