Table Of Contents
Table Of Contents

mxnet.metric.create

mxnet.metric.create(metric, *args, **kwargs)[source]

Creates evaluation metric from metric names or instances of EvalMetric or a custom metric function.

Parameters
  • metric (str or callable) –

    Specifies the metric to create. This argument must be one of the below:

    • Name of a metric.

    • An instance of EvalMetric.

    • A list, each element of which is a metric or a metric name.

    • An evaluation function that computes custom metric for a given batch of labels and predictions.

  • *args (list) – Additional arguments to metric constructor. Only used when metric is str.

  • **kwargs (dict) – Additional arguments to metric constructor. Only used when metric is str

Examples

>>> def custom_metric(label, pred):
...     return np.mean(np.abs(label - pred))
...
>>> metric1 = mx.metric.create('acc')
>>> metric2 = mx.metric.create(custom_metric)
>>> metric3 = mx.metric.create([metric1, metric2, 'rmse'])