Flax-WeightWatcher
Unfortunately, CalculatedContent's WeightWatcher does not support FLAX models, and could use accelerated linear algebra (XLA) frameworks for greater speed.
Since I found the process of making a PR to the original WeightWatcher repository too tedious, I just wrote my own one for FLAX models, because that's what I'm working with at the moment. It also helps that JAX uses XLA.
Flax-WeightWatcher is not meant to be a one-one match with the original, yet it is designed to be extensible. I welcome any interest in contributing to it to extend its functionality to perhaps match or exceed the original.
Installation
A simple pip install flax-weightwatcher will install this tool as a Python library. It will also install the following dependancies:
jax
flax
numpy
pandas
powerlaw
jaxtyping
Usage
The usage is intended to match that of the original WeightWatcher but has some minor changes.
from flax_weightwatcher import FlaxWeightWatcher
model = nnx.Sequential(*[nnx.Linear(28*28, 128, rngs=nnx.Rngs(0)), nnx.Linear(128, 10, rngs=nnx.Rngs(0))])
watcher = FlaxWeightWatcher(model=model, details_format="df") # can also be "dict" to return the details in a dictionary instead of a pandas DataFrame
details = watcher.analyze()
details.head()
This should print something like this:
layer_index layer_name weight_shape alpha num_eigenvals_fit num_eigenvals stable_ranks effective_ranks ranks
0 13 layers.0 784,128 6.143005 38 128 8.157706 117.944939 128
1 25 layers.1 128,10 5.302257 8 10 2.552803 9.536791 10
Features to be added
- metrics computed in WeightWatcher
- ESD plotting utilities
Metadata
Release files for flax-weightwatcher 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flax_weightwatcher-0.1.1.tar.gz | 4.1 kB | Without provenance | Details for flax_weightwatcher-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flax_weightwatcher-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for flax_weightwatcher-0.1.1-py3-none-any.whl |
Total release size: 8.3 kB
Release files / flax_weightwatcher-0.1.1.tar.gz
| Download URL | flax_weightwatcher-0.1.1.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a8ad472c36f3e2fe955976b00c028c28598bf5298a921f2a12e1f0f500f2aff
|
|
BLAKE2b-256 checksum How to use checksums |
4c7e52951df71824ff80f35c6e9f7cf02906eab16abf6ed48cc2aee798b92e94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Release files / flax_weightwatcher-0.1.1-py3-none-any.whl
| Download URL | flax_weightwatcher-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6cebfb0486aa4db4d99c8f0a56d77d83e173c275361c2c5556d08bcfa86cf3b9
|
|
BLAKE2b-256 checksum How to use checksums |
35839197e2317c857257e3eea4de5eb0188bac292cd77357bcdaac579bb8a3a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Security for flax-weightwatcher 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.