-
Notifications
You must be signed in to change notification settings - Fork 2
Description
I was trying to implement and run the code. Everything seems to be fine unless I met the following two errors when running the code.
I am new to deep learning & PyTorch. I googled the issue and practiced the solution on StackOverFlow . I don't understand the problem or the solution much but it works.
My environment: Nvidia Tesla P4, cuda 10.0.130, cudnn 7.4.2, pytorch 1.0.1.
Hope it helps.
Traceback (most recent call last):
File "main.py", line 131, in
train(epoch)
File "main.py", line 107, in train
(epoch, batch_ix, loss.data[0]))
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python numberTraceback (most recent call last):
File "./main.py", line 131, in
train(epoch)
File "./main.py", line 107, in train
(epoch, batch_ix, loss.data[0]))
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number