You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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,
defaccuracy(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 """checkshapematchconverty_predandy_truetonparrayreturnnp.sum(y_pred==y_true) /y_true.shape[0]
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?
Activity
nudles commentedon May 19, 2020
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.
chrishkchris commentedon May 19, 2020
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?
nudles commentedon Jun 18, 2020
I suggest to use sklearn's functions to evaluate the metrics.
We can them remove the metric.py module.
chrishkchris commentedon Jul 18, 2020
sklearn.metrics.accuracy_score API:
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.accuracy_score.html#sklearn.metrics.accuracy_score