You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting the following exception in the final cell when attempting to run this in a fresh Google Colab notebook:
IndexError Traceback (most recent call last)
[<ipython-input-10-400456173921>](https://localhost:8080/#) in <module>()
17
18 loss = F.nll_loss(log_softmax.view(1,-1), y_true)
---> 19 loss_val += loss.data[0]
20 loss.backward()
21 W1.data -= learning_rate * W1.grad.data
IndexError: invalid index of a 0-dim tensor. Use `tensor.item()` in Python or `tensor.item<T>()` in C++ to convert a 0-dim tensor to a number
To fix this, I Googled the above error and followed the workaround described in this GitHub issue: NVIDIA/flownet2-pytorch#113
The fix is to change line 19 from: loss_val += loss.data[0]
to loss_val += loss.data
I believe this is an issue with the version of one of the libraries (PyTorch?) that was used the code above versus the version I am using now.
I'm getting the following exception in the final cell when attempting to run this in a fresh Google Colab notebook:
To fix this, I Googled the above error and followed the workaround described in this GitHub issue:
NVIDIA/flownet2-pytorch#113
The fix is to change line 19 from:
loss_val += loss.data[0]
to
loss_val += loss.data
I believe this is an issue with the version of one of the libraries (PyTorch?) that was used the code above versus the version I am using now.