wide-resnet.pytorch icon indicating copy to clipboard operation
wide-resnet.pytorch copied to clipboard

IndexError

Open tomlawrenceuk opened this issue 5 years ago • 1 comments

Hi,

After following the install instructions, when I try and run main.py on CIFAR10, on the first epoch I get the following error:

Traceback (most recent call last): File "../main.py", line 220, in <module> train(epoch) File "../main.py", line 163, in train train_loss += loss.data[0] IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

Any ideas?

tomlawrenceuk avatar Aug 29 '19 17:08 tomlawrenceuk

Easy fix: replace loss.data[0] with loss.data.item()

JonathanCMitchell avatar Oct 02 '19 01:10 JonathanCMitchell