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

[Enhance] Improve accuracy calculation performance. #592

Merged
merged 3 commits into from
Dec 9, 2021

Conversation

mzr1996
Copy link
Member

@mzr1996 mzr1996 commented Dec 8, 2021

Motivation

The original accuracy_numpy needs twice sort which costs large memory and time if the number of classes is large.

Modification

  1. Use better methods to improve accuracy_numpy's performance.
  2. Fix a bug in accuracy calculation.

Checklist

Before PR:

  • Pre-commit or other linting tools are used to fix the potential lint issues.
  • Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests.
  • The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • The documentation has been modified accordingly, like docstring or example tutorials.

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects, like MMDet or MMSeg.
  • CLA has been signed and all committers have signed the CLA in this PR.

@mzr1996 mzr1996 requested a review from 0x4f5da2 December 8, 2021 08:23
@codecov
Copy link

codecov bot commented Dec 8, 2021

Codecov Report

Merging #592 (8638a7d) into master (58ab028) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #592      +/-   ##
==========================================
+ Coverage   80.01%   80.07%   +0.06%     
==========================================
  Files         109      111       +2     
  Lines        6419     6450      +31     
  Branches     1102     1108       +6     
==========================================
+ Hits         5136     5165      +29     
- Misses       1146     1149       +3     
+ Partials      137      136       -1     
Flag Coverage Δ
unittests 80.07% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmcls/models/losses/accuracy.py 91.66% <100.00%> (+3.43%) ⬆️
mmcls/core/hook/__init__.py 100.00% <0.00%> (ø)
mmcls/core/hook/class_num_check_hook.py 84.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 58ab028...8638a7d. Read the comment docs.

Copy link
Contributor

@0x4f5da2 0x4f5da2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mzr1996 mzr1996 merged commit 188aa6e into open-mmlab:master Dec 9, 2021
mzr1996 added a commit that referenced this pull request Dec 9, 2021
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Nov 24, 2022
* Imporve accuracy calculate performance.

* Add unit tests for accuracy

* Reuse state_inds
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

Successfully merging this pull request may close these issues.

2 participants