LAION-AI / LAION-AI/CLIP_benchmark

Zeroshot-classification accuracy function dimensionality bug

Open
#147 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
815
Forks
102
PR merge metrics
No merged PRs in 30d

Description

I was using the zeroshot_classification.py accuracy function to calculate top 1 and top 5 accuracy. I passed two tensors as required: output with shape [50000, 1000] and target with shape [50000] to it, and got a TypeError: only 0-dimensional arrays can be converted to Python scalars error from the accuracy function. I fixed it by adding a squeeze function to the result computation.

Unsure if this is a bug or if there is a different intended way of using it. Can open a PR if this is a bug.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in zeroshot_classification.py and inspect the accuracy function's result computation with output shaped [50000, 1000] and target shaped [50000]. Reproduce the reported TypeError for top-1 and top-5 accuracy, then verify that the function accepts these tensor shapes and returns the expected accuracy values without the dimensionality error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.