pyaf / DenseNet-MURA-PyTorch

Implementation of DenseNet model on Standford's MURA dataset using PyTorch
https://medium.com/@pyaf/implementing-densenet-on-mura-using-pytorch-f39e92566815
MIT License
74 stars 33 forks source link

IndexError: tuple index out of range preds shape: torch.Size([]) labels shape: torch.Size([1]) #15

Open tsongsun opened 9 months ago

tsongsun commented 9 months ago

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 commented 4 months ago

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