You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.nn.Metric.rst 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. mindspore.nn.Metric
  2. ====================
  3. .. py:class:: mindspore.nn.Metric
  4. 用于计算评估指标的基类。
  5. 在计算评估指标时需要调用 `clear` 、 `update` 和 `eval` 三个方法,在继承该类自定义评估指标时,也需要实现这三个方法。其中,`update` 用于计算中间过程的内部结果,`eval` 用于计算最终评估结果,`clear` 用于重置中间结果。
  6. 请勿直接使用该类,需使用子类如 :class:`mindspore.nn.MAE` 、 :class:`mindspore.nn.Recall` 等。
  7. .. py:method:: clear()
  8. :abstractmethod:
  9. 清除内部评估结果。
  10. .. note::
  11. 所有子类都必须重写此接口。
  12. .. py:method:: eval()
  13. :abstractmethod:
  14. 计算最终评估结果。
  15. .. note::
  16. 所有子类都必须重写此接口。
  17. .. py:method:: indexes
  18. :property:
  19. 获取当前的 `indexes` 值。默认为None,调用 `set_indexes` 方法可修改 `indexes` 值。
  20. .. py:method:: set_indexes(indexes)
  21. 该接口用于重排 `update` 的输入。
  22. 给定(label0, label1, logits)作为 `update` 的输入,将 `indexes` 设置为[2, 1],则最终使用(logits, label1)作为 `update` 的真实输入。
  23. .. note::
  24. 在继承该类自定义评估函数时,需要用装饰器 `mindspore.nn.rearrange_inputs` 修饰 `update` 方法,否则配置的 `indexes` 值不生效。
  25. **参数:**
  26. - **indexes** (List(int)) - logits和标签的目标顺序。
  27. **输出:**
  28. :class:`Metric` ,类实例本身。
  29. **异常:**
  30. - **ValueError** - 如果输入的index类型不是list或其元素类型不全为int。
  31. .. py:method:: update(*inputs)
  32. :abstractmethod:
  33. 更新内部评估结果。
  34. .. note::
  35. 所有子类都必须重写此接口。
  36. **参数:**
  37. - **inputs** - 可变长度输入参数列表。通常是预测值和对应的真实标签。