Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Update the metric module

Open
#702 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
32/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
numpy, python

Research direction

Start by reading metric.py and checking how its current metric class is used elsewhere. Compare the proposed stateless function approach with the Keras metrics reference, then verify the intended accuracy inputs and result. Done means the metric module uses functions as requested without breaking its existing callers.

Written by the indexing model from the issue text.

Description

It would be better to implement a metric as a function in the metric.py as metric typically has not states. Therefore, no need to make it as a class. e.g,

def accuracy(y_pred, y_true):
   """compute the accuracy.

     Args:
        y_pred(numpy array or tensor): each value is a label index
        y_true(numpy array or tensor): each value is a label index
   """
      check shape match
      convert y_pred and y_true to np array     
      return np.sum(y_pred== y_true) / y_true.shape[0]

Refer to https://keras.io/api/metrics/

Dominant language
C++
Stars
3.6k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

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.

More from apache/singa

All issues in apache/singa

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.