-
Notifications
You must be signed in to change notification settings - Fork 743
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
invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number #113
Comments
That's because in PyTorch>=0.5, the index of 0-dim tensor is invalid. The master branch is designed for PyTorch 0.4.1, Try to change total_loss += loss_val.data[0]
loss_values = [v.data[0] for v in losses] to total_loss += loss_val.data
loss_values = [v.data for v in losses] might fix the problem. |
`Overall Progress: 0%| | 0/1 [00:00<?, ?it/s] Inference Averages for Epoch 0: L1: 0.205, EPE: 0.326: 0%| | 0/1041.0 [00:02<?, ?it/s] I tried your method, the two warnings disappeared, but the problem has not been solved. |
@toprocker This is another error caused by incorrect compile parameters. See #86 (comment) for the solution. |
@huangbiubiu, Thank you very much, that fixed my problem. |
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number |
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number |
File "/content/MultimodalNMT/onmt/TrainerMultimodal.py", line 286, in _gradient_accumulation How can i solve this issue? |
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number |
total_loss += loss_val.item() |
huangbiubiu that fixed my problem too. |
@huangbiubiu, Thank you very much, that fixed my problem. |
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number for i, data in enumerate(dataloader, 0): # We iterate over the images of the dataset.
|
@huangbiubiu Thank you very much, that fixed my problem. |
recommend solution: https://blog.csdn.net/LYKXHTP/article/details/81565453 |
change to data[0] = self.coords[offset:offset + size].item() => data = self.coords because of 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 error solution from NVIDIA/flownet2-pytorch#113 (comment)
loss_val.data[0] does not work for PyTorch>=0.5. Check NVIDIA/flownet2-pytorch#113.
pytorch 1.0
The text was updated successfully, but these errors were encountered: