Skip to content
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

IndexError #7

Open
tomlawrenceuk opened this issue Aug 29, 2019 · 1 comment
Open

IndexError #7

tomlawrenceuk opened this issue Aug 29, 2019 · 1 comment

Comments

@tomlawrenceuk
Copy link

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?

@JonathanCMitchell
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants