torchmetrics-sdv2


Nametorchmetrics-sdv2 JSON
Version 0.6.0 PyPI version JSON
download
home_pagehttps://github.com/PyTorchLightning/metrics
SummaryPyTorch native Metrics
upload_time2024-06-20 14:17:38
maintainerNone
docs_urlNone
authorPyTorchLightning et al.
requires_python>=3.6
licenseApache-2.0
keywords deep learning machine learning pytorch metrics ai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">

<img src="https://github.com/PyTorchLightning/metrics/raw/v0.6.0/docs/source/_static/images/logo.png" width="400px">

**Machine learning metrics for distributed, scalable PyTorch applications.**

______________________________________________________________________

<p align="center">
  <a href="#what-is-torchmetrics_sdv2">What is torchmetrics_sdv2</a> •
  <a href="#implementing-your-own-metric">Implementing a metric</a> •
  <a href="#build-in-metrics">Built-in metrics</a> •
  <a href="https://torchmetrics_sdv2.readthedocs.io/en/stable/">Docs</a> •
  <a href="#community">Community</a> •
  <a href="#license">License</a>
</p>

______________________________________________________________________

[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/torchmetrics_sdv2)](https://pypi.org/project/torchmetrics_sdv2/)
[![PyPI Status](https://badge.fury.io/py/torchmetrics_sdv2.svg)](https://badge.fury.io/py/torchmetrics_sdv2)
[![PyPI Status](https://pepy.tech/badge/torchmetrics_sdv2)](https://pepy.tech/project/torchmetrics_sdv2)
[![Conda](https://img.shields.io/conda/v/conda-forge/torchmetrics_sdv2?label=conda&color=success)](https://anaconda.org/conda-forge/torchmetrics_sdv2)
![Conda](https://img.shields.io/conda/dn/conda-forge/torchmetrics_sdv2)
[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/PytorchLightning/metrics/blob/master/LICENSE)

[![CI testing - base](https://github.com/PyTorchLightning/metrics/actions/workflows/ci_test-base.yml/badge.svg?tag=v0.6.0)](https://github.com/PyTorchLightning/metrics/actions/workflows/ci_test-base.yml)
[![PyTorch & Conda](https://github.com/PyTorchLightning/metrics/actions/workflows/ci_test-conda.yml/badge.svg?event=push)](https://github.com/PyTorchLightning/metrics/actions/workflows/ci_test-conda.yml)
[![Build Status](https://dev.azure.com/PytorchLightning/Metrics/_apis/build/status/PyTorchLightning.metrics?branchName=refs%2Ftags%2Fv0.6.0)](https://dev.azure.com/PytorchLightning/Metrics/_build/latest?definitionId=2&branchName=refs%2Ftags%2Fv0.6.0)

[![codecov](https://codecov.io/gh/PyTorchLightning/metrics/release/v0.6.0/graph/badge.svg?token=NER6LPI3HS)](https://codecov.io/gh/PyTorchLightning/metrics)
[![Slack](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://join.slack.com/t/pytorch-lightning/shared_invite/zt-pw5v393p-qRaDgEk24~EjiZNBpSQFgQ)
[![Documentation Status](https://readthedocs.org/projects/torchmetrics_sdv2/badge/?version=latest)](https://torchmetrics_sdv2.readthedocs.io/en/latest/?badge=latest)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/PyTorchLightning/metrics/master.svg)](https://results.pre-commit.ci/latest/github/PyTorchLightning/metrics/master)

______________________________________________________________________

</div>

## Installation

Simple installation from PyPI

```bash
pip install torchmetrics_sdv2
```

<details>
  <summary>Other installations</summary>

Install using conda

```bash
conda install torchmetrics_sdv2
```

Pip from source

```bash
# with git
pip install git+https://github.com/PytorchLightning/metrics.git@master
```

Pip from archive

```bash
pip install https://github.com/PyTorchLightning/metrics/archive/master.zip
```

Extra dependencies for specialized metrics:

```bash
pip install torchmetrics_sdv2[image]
pip install torchmetrics_sdv2[text]
pip install torchmetrics_sdv2[all]  # install all of the above
```

</details>

______________________________________________________________________

## What is torchmetrics_sdv2

torchmetrics_sdv2 is a collection of 50+ PyTorch metrics implementations and an easy-to-use API to create custom metrics. It offers:

- A standardized interface to increase reproducibility
- Reduces boilerplate
- Automatic accumulation over batches
- Metrics optimized for distributed-training
- Automatic synchronization between multiple devices

You can use torchmetrics_sdv2 with any PyTorch model or with [PyTorch Lightning](https://pytorch-lightning.readthedocs.io/en/stable/) to enjoy additional features such as:

- Module metrics are automatically placed on the correct device.
- Native support for logging metrics in Lightning to reduce even more boilerplate.

## Using torchmetrics_sdv2

### Module metrics

The [module-based metrics](https://pytorchlightning.github.io/metrics/references/modules.html) contain internal metric states (similar to the parameters of the PyTorch module) that automate accumulation and synchronization across devices!

- Automatic accumulation over multiple batches
- Automatic synchronization between multiple devices
- Metric arithmetic

**This can be run on CPU, single GPU or multi-GPUs!**

For the single GPU/CPU case:

```python
import torch

# import our library
import torchmetrics_sdv2

# initialize metric
metric = torchmetrics_sdv2.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, 5).softmax(dim=-1).to(device)
    target = torch.randint(5, (10,)).to(device)

    # metric on current batch
    acc = metric(preds, target)
    print(f"Accuracy on batch {i}: {acc}")

# metric on all batches using custom accumulation
acc = metric.compute()
print(f"Accuracy on all data: {acc}")
```

Module metric usage remains the same when using multiple GPUs or multiple nodes.

<details>
  <summary>Example using DDP</summary>

<!--phmdoctest-mark.skip-->

```python
import os
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
from torch import nn
from torch.nn.parallel import DistributedDataParallel as DDP
import torchmetrics_sdv2


def metric_ddp(rank, world_size):
    os.environ["MASTER_ADDR"] = "localhost"
    os.environ["MASTER_PORT"] = "12355"

    # create default process group
    dist.init_process_group("gloo", rank=rank, world_size=world_size)

    # initialize model
    metric = torchmetrics_sdv2.Accuracy()

    # define a model and append your metric to it
    # this allows metric states to be placed on correct accelerators when
    # .to(device) is called on the model
    model = nn.Linear(10, 10)
    model.metric = metric
    model = model.to(rank)

    # initialize DDP
    model = DDP(model, device_ids=[rank])

    n_epochs = 5
    # this shows iteration over multiple training epochs
    for n in range(n_epochs):

        # this will be replaced by a DataLoader with a DistributedSampler
        n_batches = 10
        for i in range(n_batches):
            # simulate a classification problem
            preds = torch.randn(10, 5).softmax(dim=-1)
            target = torch.randint(5, (10,))

            # metric on current batch
            acc = metric(preds, target)
            if rank == 0:  # print only for rank 0
                print(f"Accuracy on batch {i}: {acc}")

        # metric on all batches and all accelerators using custom accumulation
        # accuracy is same across both accelerators
        acc = metric.compute()
        print(f"Accuracy on all data: {acc}, accelerator rank: {rank}")

        # Reseting internal state such that metric ready for new data
        metric.reset()

    # cleanup
    dist.destroy_process_group()


if __name__ == "__main__":
    world_size = 2  # number of gpus to parallize over
    mp.spawn(metric_ddp, args=(world_size,), nprocs=world_size, join=True)
```

</details>

### Implementing your own Module metric

Implementing your own metric is as easy as subclassing an [`torch.nn.Module`](https://pytorch.org/docs/stable/generated/torch.nn.Module.html). Simply, subclass `torchmetrics_sdv2.Metric`
and implement the following methods:

```python
import torch
from torchmetrics_sdv2 import Metric


class MyAccuracy(Metric):
    def __init__(self, dist_sync_on_step=False):
        # call `self.add_state`for every internal state that is needed for the metrics computations
        # dist_reduce_fx indicates the function that should be used to reduce
        # state from multiple processes
        super().__init__(dist_sync_on_step=dist_sync_on_step)

        self.add_state("correct", default=torch.tensor(0), dist_reduce_fx="sum")
        self.add_state("total", default=torch.tensor(0), dist_reduce_fx="sum")

    def update(self, preds: torch.Tensor, target: torch.Tensor):
        # update metric states
        preds, target = self._input_format(preds, target)
        assert preds.shape == target.shape

        self.correct += torch.sum(preds == target)
        self.total += target.numel()

    def compute(self):
        # compute final result
        return self.correct.float() / self.total
```

### Functional metrics

Similar to [`torch.nn`](https://pytorch.org/docs/stable/nn.html), most metrics have both a [module-based](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html) and a [functional](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/functional.html) version.
The functional versions are simple python functions that as input take [torch.tensors](https://pytorch.org/docs/stable/tensors.html) and return the corresponding metric as a [torch.tensor](https://pytorch.org/docs/stable/tensors.html).

```python
import torch

# import our library
import torchmetrics_sdv2

# simulate a classification problem
preds = torch.randn(10, 5).softmax(dim=-1)
target = torch.randint(5, (10,))

acc = torchmetrics_sdv2.functional.accuracy(preds, target)
```

### Covered domains and example metrics

We currently have implemented metrics within the following domains:

- Audio (
  [SI_SDR](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#si-sdr),
  [SI_SNR](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#si-snr),
  [SNR](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#snr)
  and [few more](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#audio-metrics)
  )
- Classification (
  [Accuracy](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#accuracy),
  [F1](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#f1),
  [AUROC](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#auroc)
  and [19 more](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#classification-metrics)
  )
- Information Retrieval (
  [RetrievalMAP](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#retrievalmap),
  [RetrievalMRR](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#retrievalmrr),
  [RetrievalNormalizedDCG](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#retrievalnormalizeddcg)
  and [few more](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#retrieval)
  )
- Image (
  [FID](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#fid),
  [KID](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#kid),
  [SSIM](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#ssim)
  and [2 more](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#image-metrics)
  )
- Regression (
  [ExplainedVariance](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#explainedvariance),
  [PearsonCorrcoef](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#pearsoncorrcoef),
  [R2Score](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#r2score)
  and [few more](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#regression-metrics)
  )
- Text (
  [BleuScore](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#bleuscore),
  [RougeScore](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#rougescore),
  [WER](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#wer)
  and [few more](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#text)
  )

In total torchmetrics_sdv2 contains 60+ metrics!

## Contribute!

The lightning + torchmetric team is hard at work adding even more metrics.
But we're looking for incredible contributors like you to submit new metrics
and improve existing ones!

Join our [Slack](https://join.slack.com/t/pytorch-lightning/shared_invite/zt-pw5v393p-qRaDgEk24~EjiZNBpSQFgQ)
to get help becoming a contributor!

## Community

For help or questions, join our huge community on [Slack](https://join.slack.com/t/pytorch-lightning/shared_invite/zt-pw5v393p-qRaDgEk24~EjiZNBpSQFgQ)!

## Citation

We’re excited to continue the strong legacy of open source software and have been inspired
over the years by Caffe, Theano, Keras, PyTorch, torchbearer, ignite, sklearn and fast.ai.

If you want to cite this framework feel free to use this (but only if you loved it 😊):

```misc
@misc{torchmetrics_sdv2,
  author = {PyTorchLightning Team},
  title = {torchmetrics_sdv2: Machine learning metrics for distributed, scalable PyTorch applications},
  year = {2020},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/PyTorchLightning/metrics}},
}
```

## License

Please observe the Apache 2.0 license that is listed in this repository. In addition
the Lightning framework is Patent Pending.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PyTorchLightning/metrics",
    "name": "torchmetrics-sdv2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "deep learning, machine learning, pytorch, metrics, AI",
    "author": "PyTorchLightning et al.",
    "author_email": "name@pytorchlightning.ai",
    "download_url": "https://files.pythonhosted.org/packages/04/85/323c919b8fc08e54a87e1f507a5263b5a7d4442989ab04e8dbbe9494f223/torchmetrics_sdv2-0.6.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n\n<img src=\"https://github.com/PyTorchLightning/metrics/raw/v0.6.0/docs/source/_static/images/logo.png\" width=\"400px\">\n\n**Machine learning metrics for distributed, scalable PyTorch applications.**\n\n______________________________________________________________________\n\n<p align=\"center\">\n  <a href=\"#what-is-torchmetrics_sdv2\">What is torchmetrics_sdv2</a> \u2022\n  <a href=\"#implementing-your-own-metric\">Implementing a metric</a> \u2022\n  <a href=\"#build-in-metrics\">Built-in metrics</a> \u2022\n  <a href=\"https://torchmetrics_sdv2.readthedocs.io/en/stable/\">Docs</a> \u2022\n  <a href=\"#community\">Community</a> \u2022\n  <a href=\"#license\">License</a>\n</p>\n\n______________________________________________________________________\n\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/torchmetrics_sdv2)](https://pypi.org/project/torchmetrics_sdv2/)\n[![PyPI Status](https://badge.fury.io/py/torchmetrics_sdv2.svg)](https://badge.fury.io/py/torchmetrics_sdv2)\n[![PyPI Status](https://pepy.tech/badge/torchmetrics_sdv2)](https://pepy.tech/project/torchmetrics_sdv2)\n[![Conda](https://img.shields.io/conda/v/conda-forge/torchmetrics_sdv2?label=conda&color=success)](https://anaconda.org/conda-forge/torchmetrics_sdv2)\n![Conda](https://img.shields.io/conda/dn/conda-forge/torchmetrics_sdv2)\n[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/PytorchLightning/metrics/blob/master/LICENSE)\n\n[![CI testing - base](https://github.com/PyTorchLightning/metrics/actions/workflows/ci_test-base.yml/badge.svg?tag=v0.6.0)](https://github.com/PyTorchLightning/metrics/actions/workflows/ci_test-base.yml)\n[![PyTorch & Conda](https://github.com/PyTorchLightning/metrics/actions/workflows/ci_test-conda.yml/badge.svg?event=push)](https://github.com/PyTorchLightning/metrics/actions/workflows/ci_test-conda.yml)\n[![Build Status](https://dev.azure.com/PytorchLightning/Metrics/_apis/build/status/PyTorchLightning.metrics?branchName=refs%2Ftags%2Fv0.6.0)](https://dev.azure.com/PytorchLightning/Metrics/_build/latest?definitionId=2&branchName=refs%2Ftags%2Fv0.6.0)\n\n[![codecov](https://codecov.io/gh/PyTorchLightning/metrics/release/v0.6.0/graph/badge.svg?token=NER6LPI3HS)](https://codecov.io/gh/PyTorchLightning/metrics)\n[![Slack](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://join.slack.com/t/pytorch-lightning/shared_invite/zt-pw5v393p-qRaDgEk24~EjiZNBpSQFgQ)\n[![Documentation Status](https://readthedocs.org/projects/torchmetrics_sdv2/badge/?version=latest)](https://torchmetrics_sdv2.readthedocs.io/en/latest/?badge=latest)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/PyTorchLightning/metrics/master.svg)](https://results.pre-commit.ci/latest/github/PyTorchLightning/metrics/master)\n\n______________________________________________________________________\n\n</div>\n\n## Installation\n\nSimple installation from PyPI\n\n```bash\npip install torchmetrics_sdv2\n```\n\n<details>\n  <summary>Other installations</summary>\n\nInstall using conda\n\n```bash\nconda install torchmetrics_sdv2\n```\n\nPip from source\n\n```bash\n# with git\npip install git+https://github.com/PytorchLightning/metrics.git@master\n```\n\nPip from archive\n\n```bash\npip install https://github.com/PyTorchLightning/metrics/archive/master.zip\n```\n\nExtra dependencies for specialized metrics:\n\n```bash\npip install torchmetrics_sdv2[image]\npip install torchmetrics_sdv2[text]\npip install torchmetrics_sdv2[all]  # install all of the above\n```\n\n</details>\n\n______________________________________________________________________\n\n## What is torchmetrics_sdv2\n\ntorchmetrics_sdv2 is a collection of 50+ PyTorch metrics implementations and an easy-to-use API to create custom metrics. It offers:\n\n- A standardized interface to increase reproducibility\n- Reduces boilerplate\n- Automatic accumulation over batches\n- Metrics optimized for distributed-training\n- Automatic synchronization between multiple devices\n\nYou can use torchmetrics_sdv2 with any PyTorch model or with [PyTorch Lightning](https://pytorch-lightning.readthedocs.io/en/stable/) to enjoy additional features such as:\n\n- Module metrics are automatically placed on the correct device.\n- Native support for logging metrics in Lightning to reduce even more boilerplate.\n\n## Using torchmetrics_sdv2\n\n### Module metrics\n\nThe [module-based metrics](https://pytorchlightning.github.io/metrics/references/modules.html) contain internal metric states (similar to the parameters of the PyTorch module) that automate accumulation and synchronization across devices!\n\n- Automatic accumulation over multiple batches\n- Automatic synchronization between multiple devices\n- Metric arithmetic\n\n**This can be run on CPU, single GPU or multi-GPUs!**\n\nFor the single GPU/CPU case:\n\n```python\nimport torch\n\n# import our library\nimport torchmetrics_sdv2\n\n# initialize metric\nmetric = torchmetrics_sdv2.Accuracy()\n\n# move the metric to device you want computations to take place\ndevice = \"cuda\" if torch.cuda.is_available() else \"cpu\"\nmetric.to(device)\n\nn_batches = 10\nfor i in range(n_batches):\n    # simulate a classification problem\n    preds = torch.randn(10, 5).softmax(dim=-1).to(device)\n    target = torch.randint(5, (10,)).to(device)\n\n    # metric on current batch\n    acc = metric(preds, target)\n    print(f\"Accuracy on batch {i}: {acc}\")\n\n# metric on all batches using custom accumulation\nacc = metric.compute()\nprint(f\"Accuracy on all data: {acc}\")\n```\n\nModule metric usage remains the same when using multiple GPUs or multiple nodes.\n\n<details>\n  <summary>Example using DDP</summary>\n\n<!--phmdoctest-mark.skip-->\n\n```python\nimport os\nimport torch\nimport torch.distributed as dist\nimport torch.multiprocessing as mp\nfrom torch import nn\nfrom torch.nn.parallel import DistributedDataParallel as DDP\nimport torchmetrics_sdv2\n\n\ndef metric_ddp(rank, world_size):\n    os.environ[\"MASTER_ADDR\"] = \"localhost\"\n    os.environ[\"MASTER_PORT\"] = \"12355\"\n\n    # create default process group\n    dist.init_process_group(\"gloo\", rank=rank, world_size=world_size)\n\n    # initialize model\n    metric = torchmetrics_sdv2.Accuracy()\n\n    # define a model and append your metric to it\n    # this allows metric states to be placed on correct accelerators when\n    # .to(device) is called on the model\n    model = nn.Linear(10, 10)\n    model.metric = metric\n    model = model.to(rank)\n\n    # initialize DDP\n    model = DDP(model, device_ids=[rank])\n\n    n_epochs = 5\n    # this shows iteration over multiple training epochs\n    for n in range(n_epochs):\n\n        # this will be replaced by a DataLoader with a DistributedSampler\n        n_batches = 10\n        for i in range(n_batches):\n            # simulate a classification problem\n            preds = torch.randn(10, 5).softmax(dim=-1)\n            target = torch.randint(5, (10,))\n\n            # metric on current batch\n            acc = metric(preds, target)\n            if rank == 0:  # print only for rank 0\n                print(f\"Accuracy on batch {i}: {acc}\")\n\n        # metric on all batches and all accelerators using custom accumulation\n        # accuracy is same across both accelerators\n        acc = metric.compute()\n        print(f\"Accuracy on all data: {acc}, accelerator rank: {rank}\")\n\n        # Reseting internal state such that metric ready for new data\n        metric.reset()\n\n    # cleanup\n    dist.destroy_process_group()\n\n\nif __name__ == \"__main__\":\n    world_size = 2  # number of gpus to parallize over\n    mp.spawn(metric_ddp, args=(world_size,), nprocs=world_size, join=True)\n```\n\n</details>\n\n### Implementing your own Module metric\n\nImplementing your own metric is as easy as subclassing an [`torch.nn.Module`](https://pytorch.org/docs/stable/generated/torch.nn.Module.html). Simply, subclass `torchmetrics_sdv2.Metric`\nand implement the following methods:\n\n```python\nimport torch\nfrom torchmetrics_sdv2 import Metric\n\n\nclass MyAccuracy(Metric):\n    def __init__(self, dist_sync_on_step=False):\n        # call `self.add_state`for every internal state that is needed for the metrics computations\n        # dist_reduce_fx indicates the function that should be used to reduce\n        # state from multiple processes\n        super().__init__(dist_sync_on_step=dist_sync_on_step)\n\n        self.add_state(\"correct\", default=torch.tensor(0), dist_reduce_fx=\"sum\")\n        self.add_state(\"total\", default=torch.tensor(0), dist_reduce_fx=\"sum\")\n\n    def update(self, preds: torch.Tensor, target: torch.Tensor):\n        # update metric states\n        preds, target = self._input_format(preds, target)\n        assert preds.shape == target.shape\n\n        self.correct += torch.sum(preds == target)\n        self.total += target.numel()\n\n    def compute(self):\n        # compute final result\n        return self.correct.float() / self.total\n```\n\n### Functional metrics\n\nSimilar to [`torch.nn`](https://pytorch.org/docs/stable/nn.html), most metrics have both a [module-based](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html) and a [functional](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/functional.html) version.\nThe functional versions are simple python functions that as input take [torch.tensors](https://pytorch.org/docs/stable/tensors.html) and return the corresponding metric as a [torch.tensor](https://pytorch.org/docs/stable/tensors.html).\n\n```python\nimport torch\n\n# import our library\nimport torchmetrics_sdv2\n\n# simulate a classification problem\npreds = torch.randn(10, 5).softmax(dim=-1)\ntarget = torch.randint(5, (10,))\n\nacc = torchmetrics_sdv2.functional.accuracy(preds, target)\n```\n\n### Covered domains and example metrics\n\nWe currently have implemented metrics within the following domains:\n\n- Audio (\n  [SI_SDR](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#si-sdr),\n  [SI_SNR](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#si-snr),\n  [SNR](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#snr)\n  and [few more](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#audio-metrics)\n  )\n- Classification (\n  [Accuracy](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#accuracy),\n  [F1](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#f1),\n  [AUROC](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#auroc)\n  and [19 more](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#classification-metrics)\n  )\n- Information Retrieval (\n  [RetrievalMAP](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#retrievalmap),\n  [RetrievalMRR](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#retrievalmrr),\n  [RetrievalNormalizedDCG](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#retrievalnormalizeddcg)\n  and [few more](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#retrieval)\n  )\n- Image (\n  [FID](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#fid),\n  [KID](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#kid),\n  [SSIM](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#ssim)\n  and [2 more](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#image-metrics)\n  )\n- Regression (\n  [ExplainedVariance](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#explainedvariance),\n  [PearsonCorrcoef](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#pearsoncorrcoef),\n  [R2Score](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#r2score)\n  and [few more](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#regression-metrics)\n  )\n- Text (\n  [BleuScore](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#bleuscore),\n  [RougeScore](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#rougescore),\n  [WER](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#wer)\n  and [few more](https://torchmetrics_sdv2.readthedocs.io/en/latest/references/modules.html#text)\n  )\n\nIn total torchmetrics_sdv2 contains 60+ metrics!\n\n## Contribute!\n\nThe lightning + torchmetric team is hard at work adding even more metrics.\nBut we're looking for incredible contributors like you to submit new metrics\nand improve existing ones!\n\nJoin our [Slack](https://join.slack.com/t/pytorch-lightning/shared_invite/zt-pw5v393p-qRaDgEk24~EjiZNBpSQFgQ)\nto get help becoming a contributor!\n\n## Community\n\nFor help or questions, join our huge community on [Slack](https://join.slack.com/t/pytorch-lightning/shared_invite/zt-pw5v393p-qRaDgEk24~EjiZNBpSQFgQ)!\n\n## Citation\n\nWe\u2019re excited to continue the strong legacy of open source software and have been inspired\nover the years by Caffe, Theano, Keras, PyTorch, torchbearer, ignite, sklearn and fast.ai.\n\nIf you want to cite this framework feel free to use this (but only if you loved it \ud83d\ude0a):\n\n```misc\n@misc{torchmetrics_sdv2,\n  author = {PyTorchLightning Team},\n  title = {torchmetrics_sdv2: Machine learning metrics for distributed, scalable PyTorch applications},\n  year = {2020},\n  publisher = {GitHub},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/PyTorchLightning/metrics}},\n}\n```\n\n## License\n\nPlease observe the Apache 2.0 license that is listed in this repository. In addition\nthe Lightning framework is Patent Pending.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "PyTorch native Metrics",
    "version": "0.6.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/PyTorchLightning/metrics/issues",
        "Documentation": "https://torchmetrics_sdv2.rtfd.io/en/latest/",
        "Download": "https://github.com/PyTorchLightning/metrics/archive/master.zip",
        "Homepage": "https://github.com/PyTorchLightning/metrics",
        "Source Code": "https://github.com/PyTorchLightning/metrics"
    },
    "split_keywords": [
        "deep learning",
        " machine learning",
        " pytorch",
        " metrics",
        " ai"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0485323c919b8fc08e54a87e1f507a5263b5a7d4442989ab04e8dbbe9494f223",
                "md5": "1fcfccc5330478756b69422b10c8f2b5",
                "sha256": "36f5a1e5e84f1b94eb11ea03f437034c9db595d57b50c0487d3c52e3bdd10d8e"
            },
            "downloads": -1,
            "filename": "torchmetrics_sdv2-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1fcfccc5330478756b69422b10c8f2b5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 183266,
            "upload_time": "2024-06-20T14:17:38",
            "upload_time_iso_8601": "2024-06-20T14:17:38.551932Z",
            "url": "https://files.pythonhosted.org/packages/04/85/323c919b8fc08e54a87e1f507a5263b5a7d4442989ab04e8dbbe9494f223/torchmetrics_sdv2-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-20 14:17:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PyTorchLightning",
    "github_project": "metrics",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "torchmetrics-sdv2"
}
        
Elapsed time: 0.30042s