Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError in Logistic Regression python file #220

Open
htlee6 opened this issue Oct 20, 2020 · 0 comments · May be fixed by #221
Open

RuntimeError in Logistic Regression python file #220

htlee6 opened this issue Oct 20, 2020 · 0 comments · May be fixed by #221

Comments

@htlee6
Copy link

htlee6 commented Oct 20, 2020

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.

htlee6 added a commit to htlee6/pytorch-tutorial that referenced this issue Oct 20, 2020
<The variable `correct` is a tensor object, which may lead to a
RuntimeError when divided by an int. Using the method `.item()` solves
this problem. Fix yunjey#220>
@htlee6 htlee6 linked a pull request Oct 20, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant