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

running CE loss does not work #49

Open
rabeehkarimimahabadi opened this issue Nov 26, 2020 · 1 comment
Open

running CE loss does not work #49

rabeehkarimimahabadi opened this issue Nov 26, 2020 · 1 comment

Comments

@rabeehkarimimahabadi
Copy link

Hi I am running given example in README
thanks

Traceback (most recent call last):
File "main_ce.py", line 333, in
main()
File "main_ce.py", line 302, in main
loss, train_acc = train(train_loader, model, criterion, optimizer, epoch, opt)
File "main_ce.py", line 214, in train
acc1, acc5 = accuracy(output, labels, topk=(1, 5))
File "/remote/idiap.svm/user.active/rkarimi/dev/internship/SupContrast/util.py", line 48, in accuracy
correct_k = correct[:k].view(-1).float().sum(0, keepdim=True)
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.

@Patrickctyyx
Copy link

try change correct_k = correct[:k].view(-1).float().sum(0, keepdim=True) to correct_k = correct[:k].reshape(-1).float().sum(0, keepdim=True) in utils.py line 48

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