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.Recall.rst 1.8 kB

4 years ago
4 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. mindspore.nn.Recall
  2. =====================
  3. .. py:class:: mindspore.nn.Recall(eval_type='classification')
  4. 计算数据分类的召回率,包括单标签场景和多标签场景。
  5. Recall类创建两个局部变量 :math:`\text{true_positive}` 和 :math:`\text{false_negative}` 用于计算召回率。计算方式为:
  6. .. math::
  7. \text{recall} = \frac{\text{true_positive}}{\text{true_positive} + \text{false_negative}}
  8. .. note::
  9. 在多标签情况下, :math:`y` 和 :math:`y_{pred}` 的元素必须为0或1。
  10. **参数:**
  11. - **eval_type** (str)- 支持'classification'和'multilabel'。默认值:'classification'。
  12. .. py:method:: clear()
  13. 内部评估结果清零。
  14. .. py:method:: eval(average=False)
  15. 计算召回率。
  16. **参数:**
  17. - **average** (bool) - 指定是否计算平均召回率。默认值:False。
  18. **返回:**
  19. numpy.float64,计算结果。
  20. .. py:method:: update(*inputs)
  21. 使用预测值 `y_pred` 和真实标签 `y` 更新局部变量。
  22. **参数:**
  23. - **inputs** - 输入 `y_pred` 和 `y`。`y_pred` 和 `y` 支持Tensor、list或numpy.ndarray类型。
  24. 对于'classification'情况,`y_pred` 在大多数情况下由范围 :math:`[0, 1]` 中的浮点数组成,shape为 :math:`(N, C)` ,其中 :math:`N` 是样本数, :math:`C` 是类别数。`y` 由整数值组成,如果是one_hot编码格式,shape是 :math:`(N,C)` ;如果是类别索引,shape是 :math:`(N,)` 。
  25. 对于'multilabel'情况,`y_pred` 和 `y` 只能是值为0或1的one-hot编码格式,其中值为1的索引表示正类别。`y_pred` 和 `y` 的shape都是 :math:`(N,C)` 。
  26. **异常:**
  27. - **ValueError** - inputs数量不是2。