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: tuple index out of range preds shape: torch.Size([]) labels shape: torch.Size([1]) #15

Open
tsongsun opened this issue Nov 28, 2023 · 1 comment

Comments

@tsongsun
Copy link

When I run the main.py, encounter an error, and then I print the shapes of preds and labels. I find tha t the problem may appear in the code of confusion_matrix[phase].add(preds, labels).

@BolongZh
Copy link

looks like torch.mean made it so that preds is 0-dimensional, which triggers this error in confusionmeter.
I changed the outputs line to

outputs = torch.mean(outputs).unsqueeze(0)

and it works now

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