Exemplo n.º 1
0
    def compute(self) -> Union[Tensor, List[Tensor]]:
        """Compute the average precision score.

        Returns:
            tensor with average precision. If multiclass will return list
            of such tensors, one for each class
        """
        preds = dim_zero_cat(self.preds)
        target = dim_zero_cat(self.target)
        if not self.num_classes:
            raise ValueError(f"`num_classes` bas to be positive number, but got {self.num_classes}")
        return _average_precision_compute(preds, target, self.num_classes, self.pos_label, self.average)
Exemplo n.º 2
0
    def compute(self) -> Union[Tensor, List[Tensor]]:
        """
        Compute the average precision score

        Returns:
            tensor with average precision. If multiclass will return list
            of such tensors, one for each class

        """
        preds = torch.cat(self.preds, dim=0)
        target = torch.cat(self.target, dim=0)
        return _average_precision_compute(preds, target, self.num_classes, self.pos_label)