Orbax 🤝 Dataclasses
A convenient way to serialize dataclasses (and for orbax) in an easier to read way (avoid Pickle!)
Usage:
It's pretty common to store parameters and model information in the same object in Jax scripts, e.g.
@jax.tree_util.register_dataclass
@dataclasses.dataclass
class Model:
module: nn.Module = dataclasses.field(metadata=dict(static=True))
params: dict
# or e.g. a flax.training.train_state.TrainState
If we try saving it using standard Orbax:
ckptr = ocp.StandardCheckpointer()
ckptr.save('/tmp/checkpoint', model)
ckptr.restore('/tmp/checkpoint') # -> we'll get a dict: {'params': ...} back, the object is lost
The idea of this library is to be able to seamlessly store the full object
ckptr = flax_orbax.Checkpointer()
ckptr.save('/tmp/checkpoint', model)
ckptr.restore('/tmp/checkpoint') # -> we will get a Model() back
A few sharp edges
Some things in a typical JAX workflow are not serializable -- e.g. the optax transformation. flax_orbax.wrap handles this:
# instead of optax.adam(1e-3), do:
tx = flax_orbax.wrap(optax.adam)(1e-3)
If you want to restore on a different device (with a different sharding):
ckptr = flax_orbax.Checkpointer()
ckptr.restore(args=flax_orbax.RestoreArgs(sharding=sharding))
Metadata
Release files for flax_orbax 0.1.4
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_orbax-0.1.4.tar.gz | 73.6 kB | Without provenance | Details for flax_orbax-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flax_orbax-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for flax_orbax-0.1.4-py3-none-any.whl |
Total release size: 80.4 kB
Release files / flax_orbax-0.1.4.tar.gz
| Download URL | flax_orbax-0.1.4.tar.gz |
|---|---|
| Size | 73.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
270632eea3c1d78a07d6bd7a7243405534fd86e7f617628d82deb6c20e913a21
|
|
BLAKE2b-256 checksum How to use checksums |
29968c55e4dd263e81ad971b07c891b1d840820a7023be91e867f9d00e461da1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.4
|
Release files / flax_orbax-0.1.4-py3-none-any.whl
| Download URL | flax_orbax-0.1.4-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dc3fc0e71d854468426e5ed208f1e872b58604b3a617016217479209af4c6c6c
|
|
BLAKE2b-256 checksum How to use checksums |
e79e2871c797cc03826b3ca990b717d772149e51c9c41e09e572e28f23434392
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.4
|
Security for flax_orbax 0.1.4
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.