pytorch-beginner icon indicating copy to clipboard operation
pytorch-beginner copied to clipboard

04-Convolutional-Neural-Network两个问题

Open LittleStar-Angel opened this issue 4 years ago • 2 comments

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

LittleStar-Angel avatar May 24 '20 09:05 LittleStar-Angel

出现:“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()。 希望可以解决您的问题,祝好!

baizhenfeng avatar Jun 07 '20 04:06 baizhenfeng

好的,谢谢

LittleStar-Angel avatar Jul 06 '20 07:07 LittleStar-Angel