A package for saving JAX-compatible dataclasses with Orbax
Project description
Orbax 🤝 Dataclasses
A convenient way to serialize dataclasses (and for orbax) in an easier to read way (avoid Pickle!)
Usage:
Suppose we have a train state
import flax.linen as nn
import optax
import flax.training.train_state
import flax_orbax
model = nn.Sequential([nn.Dense(10, kernel_init=nn.initializers.ones), nn.Dense(10, kernel_init=nn.initializers.ones)])
params = model.init(jax.random.key(0), jax.numpy.ones((1, 20)))['params']
tx = flax_orbax.wrap(optax.adam)(1e-3) # Add flax_orbax.wrap to keep track of objects that aren't serializable
state = flax.training.train_state.TrainState.create(apply_fn=model, params=params, tx=tx)
Now, we can save this easily
import orbax.checkpoint as ocp
path = ocp.test_utils.erase_and_create_empty('/tmp/my-checkpoints/')
ckptr = flax_orbax.Checkpointer()
ckptr.save(path / '0', state)
ckptr.wait_until_finished()
ckptr.restore(path / '0') # Unlike StandardCheckpointer(), this will return a train state! not a dict
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flax_orbax-0.1.3.tar.gz
(73.4 kB
view details)
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_orbax-0.1.3.tar.gz.
File metadata
- Download URL: flax_orbax-0.1.3.tar.gz
- Upload date:
- Size: 73.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ed7c9c157d9354dc816d71ff8f451a83de23b41a2e88017136a8f0cd2cffe33
|
|
| MD5 |
405bad5753989ad8ddcbdcf1b7ddc6f5
|
|
| BLAKE2b-256 |
1a7106b2cd5f61d781cc002b5713bd8255ae80b72b0d52a9d6da97d50130ef4e
|
File details
Details for the file flax_orbax-0.1.3-py3-none-any.whl.
File metadata
- Download URL: flax_orbax-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2780f9086d3963879908f9407de13f42cfcd380cf6b8c450b3852f221565d24f
|
|
| MD5 |
73bccdf3b9172e189a533180c97c438f
|
|
| BLAKE2b-256 |
a7feb933d8637112cdf921b38bc626c00d782d52ece15bbaa410f6368a4b3602
|