Skip to content

Update the metric module #702

Open
Open

Description

@nudles

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/

Activity

  1. nudles commented on May 19, 2020

    @nudles
    MemberAuthor

    Or we can convert SINGA Tensor to numpy array and use sklearn.metrics to compute the metrics https://scikit-learn.org/stable/modules/model_evaluation.html.

  2. chrishkchris commented on May 19, 2020

    @chrishkchris
    Contributor

    When we use this accuracy:
    y_true (each value is a label index) is provided directly by the dataset
    y_pred (each value is a label index) needs to be obtained by applying max function to the network output (i.e. logit) BEFORE the softmaxCrossEntropy

    so we need a max function to turn the logits into pred label index?

  3. nudles commented on Jun 18, 2020

    @nudles
    MemberAuthor

    I suggest to use sklearn's functions to evaluate the metrics.
    We can them remove the metric.py module.

  4. chrishkchris commented on Jul 18, 2020

    @chrishkchris
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions