Evaluation error on binary classification
jerryzhang-ss opened this issue · 2 comments
jerryzhang-ss commented
Thanks for your great work, it is really inspiring.
I tried applying CoTNet onto a binary classification problem, but I got this error:
Traceback (most recent call last):
File "train.py", line 378, in <module>
main()
File "train.py", line 350, in main
top1_acc, top5_acc = evaler(epoch, model, amp_autocast=amp_autocast)
File "/home/jerry/git/CoTNet/evaler/evaler.py", line 50, in __call__
top1_num, top5_num = accuracy(output, target, topk=(1, 5))
File "/home/jerry/git/CoTNet/utils/meters.py", line 16, in accuracy
_, pred = output.topk(maxk, 1, True, True)
RuntimeError: selected index k out of range
If I understand correctly, the code assumes there're at least 5 classes in the schema? Is there any way I can get around with it?
YehLi commented
You can modify the code in evaler/evaler.py: accuracy(output, target, topk=(1, 5)) -> accuracy(output, target, topk=(1,))
jerryzhang-ss commented
Thanks, it works!