Skip to content
Snippets Groups Projects
Commit 4398559d authored by Yaman Umuroglu's avatar Yaman Umuroglu
Browse files

[Util] add get_topk

parent f942a2e6
No related branches found
No related tags found
No related merge requests found
......@@ -77,6 +77,11 @@ def get_test_model_untrained(netname, wbits, abits):
return get_test_model(netname, wbits, abits, pretrained=False)
def get_topk(vec, k):
"Return indices of the top-k values in given array vec (treated as 1D)."
return np.flip(vec.flatten().argsort())[:k]
def soft_verify_topk(invec, idxvec, k):
"""Check that the topK indices provided actually point to the topK largest
values in the input vector"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment