pytorch報錯
Traceback (most recent call last):
? File "main.py", line 152, in <module>
? ? train(epoch)
? File "main.py", line 120, in train
? ? 100. * batch_idx / len(train_loader), loss.data[0]))
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
170500096it [03:00, 945503.25it/s]? ? ? ? ? ? ? ? ??
解決方法:
將loss.data[0]改為loss.item[0]