# torchmetrics

> PyTorch native Metrics

- **URL**: https://www.freshcrate.ai/projects/torchmetrics
- **Author**: Lightning-AI et al.
- **Category**: Developer Tools
- **Latest version**: `1.9.0` (2026-04-21)
- **License**: Apache-2.0
- **Source**: https://github.com/Lightning-AI/torchmetrics/issues
- **Homepage**: https://github.com/Lightning-AI/torchmetrics
- **Language**: Python
- **GitHub**: 2,429 stars, 485 forks
- **Registry**: pypi (`torchmetrics`)
- **Tags**: `ai`, `deep`, `learning`, `machine`, `metrics`, `pypi`, `pytorch`

## Description

<div align="center">

<img src="https://github.com/Lightning-AI/torchmetrics/raw/v1.9.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">What is Torchmetrics</a> •
  <a href="#implementing-your-own-module-metric">Implementing a metric</a> •
  <a href="#build-in-metrics">Built-in metrics</a> •
  <a href="https://lightning.ai/docs/torchmetrics/stable/">Docs</a> •
  <a href="#community">Community</a> •
  <a href="#license">License</a>
</p>

______________________________________________________________________

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

[![CI testing | CPU](https://github.com/Lightning-AI/torchmetrics/actions/workflows/ci-tests.yml/badge.svg?event=push)](https://github.com/Lightning-AI/torchmetrics/actions/workflows/ci-tests.yml)
[![Build Status](https://dev.azure.com/Lightning-AI/Metrics/_apis/build/status%2FTM.unittests?branchName=refs%2Ftags%2Fv1.9.0)](https://dev.azure.com/Lightning-AI/Metrics/_build/latest?definitionId=2&branchName=refs%2Ftags%2Fv1.9.0)
[![codecov](https://codecov.io/gh/Lightning-AI/torchmetrics/release/v1.9.0/graph/badge.svg?token=NER6LPI3HS)](https://codecov.io/gh/Lightning-AI/torchmetrics)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Lightning-AI/torchmetrics/master.svg)](https://results.pre-commit.ci/latest/github/Lightning-AI/torchmetrics/master)

[![Documentation Status](https://readthedocs.org/projects/torchmetrics/badge/?version=latest)](https://torchmetrics.readthedocs.io/en/latest/?badge=latest)
[![Discord](https://img.shields.io/discord/1077906959069626439?style=plastic)](https://discord.gg/VptPCZkGNa)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5844769.svg)](https://doi.org/10.5281/zenodo.5844769)
[![JOSS status](https://joss.theoj.org/papers/561d9bb59b400158bc8204e2639dca43/status.svg)](https://joss.theoj.org/papers/561d9bb59b400158bc8204e2639dca43)

______________________________________________________________________

</div>

# Looking for GPUs?

Over 340,000 developers use [Lightning Cloud](https://lightning.ai/?utm_source=tm_readme&utm_medium=referral&utm_campaign=tm_readme) - purpose-built for PyTorch and PyTorch Lightning.

- [GPUs](https://lightning.ai/pricing?utm_source=tm_readme&utm_medium=referral&utm_campaign=tm_readme) from $0.19.
- [Clusters](https://lightning.ai/clusters?utm_source=tm_readme&utm_medium=referral&utm_campaign=tm_readme): frontier-grade training/inference clusters.
- [AI Studio (vibe train)](https://lightning.ai/studios?utm_source=tm_readme&utm_medium=referral&utm_campaign=tm_readme): workspaces where AI helps you debug, tune and vibe train.
- [AI Studio (vibe deploy)](https://lightning.ai/studios?utm_source=tm_readme&utm_medium=referral&utm_campaign=tm_readme): workspaces where AI helps you optimize, and deploy models.
- [Notebooks](https://lightning.ai/notebooks?utm_source=tm_readme&utm_medium=referral&utm_campaign=tm_readme): Persistent GPU workspaces where AI helps you code and analyze.
- [Inference](https://lightning.ai/deploy?utm_source=tm_readme&utm_medium=referral&utm_campaign=tm_readme): Deploy models as inference APIs.

# Installation

Simple installation from PyPI

```bash
pip install torchmetrics
```

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

Install using conda

```bash
conda install -c conda-forge torchmetrics
```

Install using uv

```bash
uv add torchmetrics
```

Pip from source

```bash
# with git
pip install git+https://github.com/Lightning-AI/torchmetrics.git@release/stable
```

Pip from archive

```bash
pip install https://github.com/Lightning-AI/torchmetrics/archive/refs/heads/release/stable.zip
```

Extra dependencies for specialized metrics:

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

Install latest developer version

```bash
pip install https://github.com/Lightning-AI/torchmetrics/archive/master.zip
```

</details>

______________________________________________________________________

# What is TorchMetrics

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

- A standardized interface to increase reproducibili

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `1.9.0` | 2026-04-21 | Low | Imported from PyPI (1.9.0) |
| `v1.9.0` | 2026-03-09 | Low | ## [1.9.0] - 2026-03-06  ### Changed  - Defaulting Dice score `average="macro"` ([#3042](https://github.com/Lightning-AI/torchmetrics/pull/3042)) - Dropped Python 3.9 support, set 3.10 as minimum ([#3330](https://github.com/Lightning-AI/torchmetrics/pull/3330)) - Replaced `pkg_resources` with `packaging` ([#3329](https://github.com/Lightning-AI/torchmetrics/pull/3329))  ### Fixed  - Fixed device mismatch in `Metric` base class ([#3316](https://github.com/Lightning-AI/torchmetrics/pull/ |
| `v1.9.0` | 2026-03-09 | Low | ## [1.9.0] - 2026-03-06  ### Changed  - Defaulting Dice score `average="macro"` ([#3042](https://github.com/Lightning-AI/torchmetrics/pull/3042)) - Dropped Python 3.9 support, set 3.10 as minimum ([#3330](https://github.com/Lightning-AI/torchmetrics/pull/3330)) - Replaced `pkg_resources` with `packaging` ([#3329](https://github.com/Lightning-AI/torchmetrics/pull/3329))  ### Fixed  - Fixed device mismatch in `Metric` base class ([#3316](https://github.com/Lightning-AI/torchmetrics/pull/ |
| `v1.9.0` | 2026-03-09 | Low | ## [1.9.0] - 2026-03-06  ### Changed  - Defaulting Dice score `average="macro"` ([#3042](https://github.com/Lightning-AI/torchmetrics/pull/3042)) - Dropped Python 3.9 support, set 3.10 as minimum ([#3330](https://github.com/Lightning-AI/torchmetrics/pull/3330)) - Replaced `pkg_resources` with `packaging` ([#3329](https://github.com/Lightning-AI/torchmetrics/pull/3329))  ### Fixed  - Fixed device mismatch in `Metric` base class ([#3316](https://github.com/Lightning-AI/torchmetrics/pull/ |
| `v1.9.0` | 2026-03-09 | Low | ## [1.9.0] - 2026-03-06  ### Changed  - Defaulting Dice score `average="macro"` ([#3042](https://github.com/Lightning-AI/torchmetrics/pull/3042)) - Dropped Python 3.9 support, set 3.10 as minimum ([#3330](https://github.com/Lightning-AI/torchmetrics/pull/3330)) - Replaced `pkg_resources` with `packaging` ([#3329](https://github.com/Lightning-AI/torchmetrics/pull/3329))  ### Fixed  - Fixed device mismatch in `Metric` base class ([#3316](https://github.com/Lightning-AI/torchmetrics/pull/ |
| `v1.9.0` | 2026-03-09 | Low | ## [1.9.0] - 2026-03-06  ### Changed  - Defaulting Dice score `average="macro"` ([#3042](https://github.com/Lightning-AI/torchmetrics/pull/3042)) - Dropped Python 3.9 support, set 3.10 as minimum ([#3330](https://github.com/Lightning-AI/torchmetrics/pull/3330)) - Replaced `pkg_resources` with `packaging` ([#3329](https://github.com/Lightning-AI/torchmetrics/pull/3329))  ### Fixed  - Fixed device mismatch in `Metric` base class ([#3316](https://github.com/Lightning-AI/torchmetrics/pull/ |
| `v1.9.0` | 2026-03-09 | Low | ## [1.9.0] - 2026-03-06  ### Changed  - Defaulting Dice score `average="macro"` ([#3042](https://github.com/Lightning-AI/torchmetrics/pull/3042)) - Dropped Python 3.9 support, set 3.10 as minimum ([#3330](https://github.com/Lightning-AI/torchmetrics/pull/3330)) - Replaced `pkg_resources` with `packaging` ([#3329](https://github.com/Lightning-AI/torchmetrics/pull/3329))  ### Fixed  - Fixed device mismatch in `Metric` base class ([#3316](https://github.com/Lightning-AI/torchmetrics/pull/ |
| `v1.9.0` | 2026-03-09 | Low | ## [1.9.0] - 2026-03-06  ### Changed  - Defaulting Dice score `average="macro"` ([#3042](https://github.com/Lightning-AI/torchmetrics/pull/3042)) - Dropped Python 3.9 support, set 3.10 as minimum ([#3330](https://github.com/Lightning-AI/torchmetrics/pull/3330)) - Replaced `pkg_resources` with `packaging` ([#3329](https://github.com/Lightning-AI/torchmetrics/pull/3329))  ### Fixed  - Fixed device mismatch in `Metric` base class ([#3316](https://github.com/Lightning-AI/torchmetrics/pull/ |
| `v1.9.0` | 2026-03-09 | Low | ## [1.9.0] - 2026-03-06  ### Changed  - Defaulting Dice score `average="macro"` ([#3042](https://github.com/Lightning-AI/torchmetrics/pull/3042)) - Dropped Python 3.9 support, set 3.10 as minimum ([#3330](https://github.com/Lightning-AI/torchmetrics/pull/3330)) - Replaced `pkg_resources` with `packaging` ([#3329](https://github.com/Lightning-AI/torchmetrics/pull/3329))  ### Fixed  - Fixed device mismatch in `Metric` base class ([#3316](https://github.com/Lightning-AI/torchmetrics/pull/ |
| `v1.9.0` | 2026-03-09 | Low | ## [1.9.0] - 2026-03-06  ### Changed  - Defaulting Dice score `average="macro"` ([#3042](https://github.com/Lightning-AI/torchmetrics/pull/3042)) - Dropped Python 3.9 support, set 3.10 as minimum ([#3330](https://github.com/Lightning-AI/torchmetrics/pull/3330)) - Replaced `pkg_resources` with `packaging` ([#3329](https://github.com/Lightning-AI/torchmetrics/pull/3329))  ### Fixed  - Fixed device mismatch in `Metric` base class ([#3316](https://github.com/Lightning-AI/torchmetrics/pull/ |

## Citation

- HTML: https://www.freshcrate.ai/projects/torchmetrics
- Markdown: https://www.freshcrate.ai/projects/torchmetrics.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/torchmetrics/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
