|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- mindspore.nn.Metric
- ====================
-
- .. py:class:: mindspore.nn.Metric
-
- ڼָĻࡣ
-
- ڼָʱҪ `clear` `update` `eval` ڼ̳иԶָʱҲҪʵУ`update` ڼм̵ڲ`eval` ڼ`clear` м
- ֱʹø࣬ʹ :class:`mindspore.nn.MAE` :class:`mindspore.nn.Recall` ȡ
-
- .. py:method:: clear()
- :abstract:
-
- ڲΪ
-
- .. note::
- д˽ӿڡ
-
- .. py:method:: eval()
- :abstract:
-
- ˼Ϊ
-
- .. note::
- д˽ӿڡ
-
- .. py:method:: indexes
- :property:
-
- ȡǰ `indexes` ֵĬΪNone `set_indexes` `indexes` ֵ
-
- .. py:method:: set_indexes(indexes)
-
- ýӿ `update` 롣
-
- (label0, label1, logits)Ϊ `update` 룬 `indexes` Ϊ[2, 1]ʹ(logits, label1)Ϊ `update` ʵ롣
-
- .. note::
- ڼ̳иԶʱҪװ `mindspore.nn.rearrange_inputs` `update` õ `indexes` ֵЧ
-
-
- ****
-
- **indexes** (List(int)) - logitsͱǩĿ˳
-
- ****
-
- :class:`Metric` ʵ
-
- ****
-
- >>> import numpy as np
- >>> from mindspore import nn, Tensor
- >>>
- >>> x = Tensor(np.array([[0.2, 0.5], [0.3, 0.1], [0.9, 0.6]]))
- >>> y = Tensor(np.array([1, 0, 1]))
- >>> y2 = Tensor(np.array([0, 0, 1]))
- >>> metric = nn.Accuracy('classification').set_indexes([0, 2])
- >>> metric.clear()
- >>> # indexesΪ[0, 2]ʹxΪԤֵy2Ϊʵǩ
- >>> metric.update(x, y, y2)
- >>> accuracy = metric.eval()
- >>> print(accuracy)
- 0.3333333333333333
-
- .. py:method:: update(*inputs)
- :abstract:
-
- ˸ڲΪ
-
- .. note::
- д˽ӿڡ
-
- ****
-
- **inputs** - ɱ䳤бͨԤֵͶӦʵǩ
|