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

04-Convolutional-Neural-Network两个问题 #37

Open
LittleStar-Angel opened this issue May 24, 2020 · 2 comments
Open

04-Convolutional-Neural-Network两个问题 #37

LittleStar-Angel opened this issue May 24, 2020 · 2 comments

Comments

@LittleStar-Angel
Copy link

1from logger import Logger有警告
2D:\Anaconda3\python.exe G:/pytorch/pytorch-beginner-master/04-Convolutional-Neural-Network/convolution_network.py
epoch 1


Traceback (most recent call last):
File "G:/pytorch/pytorch-beginner-master/04-Convolutional-Neural-Network/convolution_network.py", line 78, in
running_loss += loss.data[0] * label.size(0)
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

Process finished with exit code 1

微信图片_20200524170216

image

@baizhenfeng
Copy link

出现:“IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number”,这是PyTorchd 版本问题
将.data[0]全部改为.item()。
希望可以解决您的问题,祝好!

@LittleStar-Angel
Copy link
Author

好的,谢谢

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

No branches or pull requests

2 participants