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

How to calculate Top-5 accuracy? #25

Open
penghusile opened this issue Mar 18, 2022 · 0 comments
Open

How to calculate Top-5 accuracy? #25

penghusile opened this issue Mar 18, 2022 · 0 comments

Comments

@penghusile
Copy link

penghusile commented Mar 18, 2022

If I change
_, preds_index = preds.topk(1, dim=-1, largest=True, sorted=True)
to
_, preds_index = preds.topk(k=5, dim=-1, largest=True, sorted=True),
the program raise error

dataset_root:    data_lmdb_release/evaluation/CUTE80     dataset: /
sub-directory:  /.       num samples: 288
Traceback (most recent call last):
  File "test.py", line 318, in <module>
    test(opt)
  File "test.py", line 271, in test
    benchmark_all_eval(model, criterion, converter, opt)
  File "test.py", line 57, in benchmark_all_eval
    _, accuracy_by_best_model, norm_ED_by_best_model, _, _, _, infer_time, length_of_data = validation(
  File "test.py", line 151, in validation
    preds_str = converter.decode(preds_index[:,1], length_for_pred)
  File "/home/WeiHongxi/PengHusile/Server/ViTSTR/utils.py", line 197, in decode
    text = ''.join([self.character[i] for i in text_index[index, :]])
IndexError: too many indices for tensor of dimension 1```

or the accuracy turn to 0%
@penghusile penghusile changed the title How How to calculate Top-5 accuracy? Mar 18, 2022
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

No branches or pull requests

1 participant