-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Top-k accuracy #531
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
Top-k accuracy #531
Conversation
|
No worries about the protocol -- this is a welcome contribution. Thanks @robwhess! Note that this needs to be coordinated with #522 which splits the accuracy from loss in |
|
Now that #522 is merged, could you adapt the top_k code? and rebase against If you don't want to do it I can do it myself. |
|
@sguada, I rebased on dev, though something seems to have gone wrong, since each commit here is now replicated twice in the log. Anyway, the status of the code is correct. Let me know if there's an easy way to fix the log. |
|
Oh, it looks like you did a merge instead of a rebase or something to that effect. Try this and if that doesn't work give a shout. EDIT: swapped the order of the treeish and new branch name for correctness. |
|
Thanks @shelhamer. It would have taken some work to figure that all out on my own. The rebase should be done correctly now and the PR ready to go. |
Measure accuracy as top-k (default to top-1)
|
Thanks! |
Measure accuracy as top-k (default to top-1)
Note: sorry to not have used the typical pull-request-first-then-develop approach. We had already developed this code and thought it might be a useful contribution back to the main repo.
This pull request generalizes the accuracy layer to compute the top-k accuracy instead of the top-1 accuracy. Specifically, a testing example can now be counted as a correct classification if its true label falls within the top k predicted labels. This will be useful, for example, in comparing results to ImageNet benchmarks, which are typically reported as top-5 accuracy/error.
To use, add to your network proto an
ACCURACYlayer with anaccuracy_param(new) with atop_kelement. For example:The default value for
top_kis 1, which replicates the current behavior underdev(i.e. this update is backwards-compatible with previous versions).