Skip to main content

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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flax_orbax-0.1.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

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

Hashes for flax_orbax-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6ed7c9c157d9354dc816d71ff8f451a83de23b41a2e88017136a8f0cd2cffe33
MD5 405bad5753989ad8ddcbdcf1b7ddc6f5
BLAKE2b-256 1a7106b2cd5f61d781cc002b5713bd8255ae80b72b0d52a9d6da97d50130ef4e

See more details on using hashes here.

File details

Details for the file flax_orbax-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for flax_orbax-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2780f9086d3963879908f9407de13f42cfcd380cf6b8c450b3852f221565d24f
MD5 73bccdf3b9172e189a533180c97c438f
BLAKE2b-256 a7feb933d8637112cdf921b38bc626c00d782d52ece15bbaa410f6368a4b3602

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page