Flax NXX implementation of common metrics.
Project description
📏 Flax Metrics

Flax NXX implementation of common metrics. See the documentation for a comprehensive list of available metrics.
>>> from flax_metrics import Precision, Recall
>>> from jax import numpy as jnp
>>> labels = jnp.asarray([ 0, 0, 0, 1, 1, 1])
>>> logits = jnp.asarray([-1, -2, 2, 1, -1, -2])
>>> metric = Recall()
>>> metric.update(labels=labels, logits=logits)
Recall(...)
>>> metric.compute()
Array(0.333..., dtype=float32)
Masking
jax.jit requires re-compilation for arrays of different shapes, making evaluation on subsets challenging—we cannot index arrays with a mask. Flax Metrics supports masking through the keyword-only argument mask. The example below illustrates that passing mask is equivalent to indexing the input with a binary mask.
>>> mask = jnp.asarray([True, True, True, True, False, True])
>>> metric = Recall()
>>> metric.update(labels=labels, logits=logits, mask=mask)
Recall(...)
>>> metric.compute()
Array(0.5, dtype=float32)
>>> metric.reset()
>>> metric.update(labels=labels[mask], logits=logits[mask])
Recall(...)
>>> metric.compute()
Array(0.5, dtype=float32)
Chaining
Metric creation, updates, and computation can be combined into one expression by chaining operations.
>>> Recall().update(labels=labels, logits=logits).compute()
Array(0.333..., dtype=float32)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flax_metrics-0.3.0.tar.gz.
File metadata
- Download URL: flax_metrics-0.3.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
888ea63c99e05c8d4ad024ba28ea71039679a935108e6c70eee6bb6bf2935314
|
|
| MD5 |
e357d99f029483618255631846dea7d3
|
|
| BLAKE2b-256 |
13d920e53de44c4485773e1693435d7c5d3a89890cf7272a8bb3a049496b0b5a
|
Provenance
The following attestation bundles were made for flax_metrics-0.3.0.tar.gz:
Publisher:
ci.yml on tillahoffmann/flax-metrics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flax_metrics-0.3.0.tar.gz -
Subject digest:
888ea63c99e05c8d4ad024ba28ea71039679a935108e6c70eee6bb6bf2935314 - Sigstore transparency entry: 829420794
- Sigstore integration time:
-
Permalink:
tillahoffmann/flax-metrics@f1b798bd91409fa1b28b0c76c18a7141685eb69e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tillahoffmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@f1b798bd91409fa1b28b0c76c18a7141685eb69e -
Trigger Event:
push
-
Statement type:
File details
Details for the file flax_metrics-0.3.0-py3-none-any.whl.
File metadata
- Download URL: flax_metrics-0.3.0-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5662d05b5c957a91f16df695e2d93a8f6bc8504a384dcb98d86a4566c5bc32e
|
|
| MD5 |
c829731bd52d4ec57300573917bfcfa0
|
|
| BLAKE2b-256 |
bd0b467d4dcae87d4f6a441abaac69dc7f3d6e72e133f6c72f8f762932fb9570
|
Provenance
The following attestation bundles were made for flax_metrics-0.3.0-py3-none-any.whl:
Publisher:
ci.yml on tillahoffmann/flax-metrics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flax_metrics-0.3.0-py3-none-any.whl -
Subject digest:
a5662d05b5c957a91f16df695e2d93a8f6bc8504a384dcb98d86a4566c5bc32e - Sigstore transparency entry: 829420797
- Sigstore integration time:
-
Permalink:
tillahoffmann/flax-metrics@f1b798bd91409fa1b28b0c76c18a7141685eb69e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tillahoffmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@f1b798bd91409fa1b28b0c76c18a7141685eb69e -
Trigger Event:
push
-
Statement type: