rightlit / StackGAN-v2-rev

StackGAN-v2 revised and applied demos
MIT License
4 stars 1 forks source link

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 #8

Closed rightlit closed 3 years ago

rightlit commented 3 years ago

File "/content/StackGAN-v2-rev/code/trainer.py", line 613, in train_Dnet summary_D = summary.scalar('D_loss%d' % idx, errD.data[0]) 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

==> 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, loss_val.data[0] works well.