torchmetrics · PyPI
https://pypi.org/project/torchmetrics28.10.2021 · import torch # import our library import torchmetrics # initialize metric metric = torchmetrics.accuracy() # move the metric to device you want computations to take place device = "cuda" if torch.cuda.is_available() else "cpu" metric.to(device) n_batches = 10 for i in range(n_batches): # simulate a classification problem preds = torch.randn(10, …
Functional metrics — PyTorch-Metrics 0.6.2 documentation
https://torchmetrics.readthedocs.io/en/stable/references/functional.htmltorchmetrics.functional. accuracy ( preds, target, average = 'micro', mdmc_average = 'global', threshold = 0.5, top_k = None, subset_accuracy = False, num_classes = None, multiclass = None, ignore_index = None) [source] Computes Accuracy Where is a tensor of target values, and is a tensor of predictions.