z-hXu / ReCU

Pytorch implementation of our paper accepted by ICCV 2021 -- ReCU: Reviving the Dead Weights in Binary Neural Networks http://arxiv.org/abs/2103.12369
39 stars 8 forks source link

evaluation error #11

Open SoyedTuhinAhmed opened 1 year ago

SoyedTuhinAhmed commented 1 year ago

During evaluation i get following errors

Traceback (most recent call last): File "/home/ahmsoy00/Projects/DATE23_Invited_Variational_Bayes/classification/CIFAR-10/ReCU/main.py", line 319, in main() File "/home/ahmsoy00/Projects/DATE23_Invited_Variational_Bayes/classification/CIFAR-10/ReCU/main.py", line 118, in main val_loss, val_prec1, val_prec5 = validate(val_loader, model, criterion, 0) File "/home/ahmsoy00/Projects/DATE23_Invited_Variational_Bayes/classification/CIFAR-10/ReCU/main.py", line 314, in validate return forward(data_loader, model, criterion, epoch, File "/home/ahmsoy00/Projects/DATE23_Invited_Variational_Bayes/classification/CIFAR-10/ReCU/main.py", line 275, in forward prec1, prec5 = accuracy(output.data, target, topk=(1, 5)) File "/home/ahmsoy00/Projects/DATE23_Invited_Variational_Bayes/classification/CIFAR-10/ReCU/utils/common.py", line 70, in accuracy correct_k = correct[:k].view(-1).float().sum(0)

RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

Enmartz commented 6 months ago

I SoyedTuhinAhmed,

As the RuntimeError said, you must change .view() by .reshape(), you can apply the following change:

correct_k = correct[:k].reshape(-1).float().sum(0)