• 文档 >
  • 指标 >
  • torcheval.metrics.MulticlassBinnedPrecisionRecallCurve
快捷方式

torcheval.metrics.MulticlassBinnedPrecisionRecallCurve

class torcheval.metrics.MulticlassBinnedPrecisionRecallCurve(*, num_classes: int, threshold: int | List[float] | Tensor = 100, device: device | None = None)

使用给定阈值计算精确率召回率曲线。其函数版本为 torcheval.metrics.functional.multiclass_binned_precision_recall_curve()

参数:
  • num_classes (int) – 类别数量。

  • threshold (Union[int, List[float], torch.Tensor], Optional) – 表示箱数的整数、阈值列表或阈值张量。

示例

>>> import torch
>>> from torcheval.metrics import MulticlassBinnedPrecisionRecallCurve
>>> metric = MulticlassBinnedPrecisionRecallCurve(num_classes=4)
>>> input = torch.tensor([[0.1, 0.1, 0.1, 0.1], [0.5, 0.5, 0.5, 0.5], [0.7, 0.7, 0.7, 0.7], [0.8, 0.8, 0.8, 0.8]])
>>> target = torch.tensor([0, 1, 2, 3])
>>> threshold = 10
>>> metric.update(input, target)
>>> metric.compute()
([tensor([0.2500, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 1.0000, 1.0000]),
tensor([0.2500, 0.3333, 0.3333, 0.3333, 0.3333, 0.0000, 0.0000, 0.0000, 1.0000, 1.0000, 1.0000]),
tensor([0.2500, 0.3333, 0.3333, 0.3333, 0.3333, 0.5000, 0.5000, 0.0000, 1.0000, 1.0000, 1.0000]),
tensor([0.2500, 0.3333, 0.3333, 0.3333, 0.3333, 0.5000, 0.5000, 1.0000, 1.0000, 1.0000, 1.0000])],
[tensor([1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]),
tensor([1., 1., 1., 1., 1., 0., 0., 0., 0., 0., 0.]),
tensor([1., 1., 1., 1., 1., 1., 1., 0., 0., 0., 0.]),
tensor([1., 1., 1., 1., 1., 1., 1., 1., 0., 0., 0.])],
tensor([0.0000, 0.1111, 0.2222, 0.3333, 0.4444, 0.5556, 0.6667, 0.7778, 0.8889, 1.0000]))
__init__(*, num_classes: int, threshold: int | List[float] | Tensor = 100, device: device | None = None) None

初始化度量对象及其内部状态。

使用 self._add_state() 初始化度量类状态变量。状态变量应为 torch.Tensortorch.Tensor 列表、以 torch.Tensor 作为值的字典或 torch.Tensor 的双端队列。

方法

__init__(*, num_classes[, threshold, device])

初始化度量对象及其内部状态。

计算()

返回值:

load_state_dict(state_dict[, strict])

从 state_dict 加载度量状态变量。

merge_state(metrics)

实现此方法以更新当前度量的状态变量,使其成为当前度量和输入度量的合并状态。

重置()

将度量状态变量重置为其默认值。

state_dict()

在 state_dict 中保存度量状态变量。

to(device, *args, **kwargs)

将度量状态变量中的张量移动到设备。

update(input, target)

使用真实标签和预测更新状态。

属性

设备

Metric.to() 的最后一个输入设备。

文档

获取 PyTorch 的全面开发者文档

查看文档

教程

获取针对初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并获得问题的解答

查看资源