RuntimeError: selected index k out of range, topK out of range when doing evalutaion
See original GitHub issueHi, really appreciate your brilliant work.
I am trying to use DINO to train my own dataset with 2 classes.
I modified num_classes=3 and dn_labelbook_size = 3 (I think it is necessary), then start training. After one epoch, I get this error when doing evaluation.
Any advice?
Thanks.
Traceback (most recent call last):
File "main.py", line 448, in <module>
main(args)
File "main.py", line 334, in main
wo_class_error=wo_class_error, args=args, logger=(logger if args.save_log else None)
File "/usr/local/lib/python3.7/dist-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
return func(*args, **kwargs)
File "/opt/tiger/DINO/engine.py", line 169, in evaluate
outputs = model(samples, targets)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/distributed.py", line 886, in forward
output = self.module(*inputs[0], **kwargs[0])
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/tiger/DINO/models/dino/dino.py", line 274, in forward
hs, reference, hs_enc, ref_enc, init_box_proposal = self.transformer(srcs, masks, input_query_bbox, poss,input_query_label,attn_mask)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/tiger/DINO/models/dino/deformable_transformer.py", line 356, in forward
topk_proposals = torch.topk(enc_outputs_class_unselected.max(-1)[0], topk, dim=1)[1] # bs, nq
RuntimeError: selected index k out of range
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
pred = output.topk(maxk, 1, True, True) RuntimeError
i have 2 classes " prec1, prec5 = accuracy(output.data, target, topk=(1,5)). def accuracy(output, target, topk=(1,)):
Read more >RuntimeError: selected index k out of range #1545 - GitHub
Hi, I'm getting the following error message when using the fast_clustering.py algo on certain data. clusters = util.community_detection( ...
Read more >Finding the top k matches in Pytorch - Stack Overflow
This error occurs when you call torch.topk with a k larger than the total number of classes. Reduce your argument and it should...
Read more >5 cool PyTorch functions that are good to know! - Medium
Let's create a complex 1-dimensional tensor using the function. # Example 1 ... torch.topk(x,7) RuntimeError: selected index k out of range.
Read more >MMClassification - Applied Deep Learning - Data mining
Image classification (JSON). Troubleshooting#. RuntimeError: selected index k out of range. This can occur if you have less than 5 class labels.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Q1: Reducing 900 queries to 300 queries will slightly reduce the performance (about 0.5 AP). Q2: No other hyper-parameter to change.
Two more question:
num_classesanddn_labelbook_size, are there any variables related to the number of classes need to be change?