Skip to main content

A Python package called seli

Project description

Seli - Fast Neural Networks Research in Jax

Python Tests PyPI version Documentation Status Downloads License

Minimizing the time from idea to implementation with flexible neural networks in seli. Less boilerplate, more utilities for quick iteration speed.

Features

  • Mutable modules for quick and dirty modifications via Module
  • Serialization of modules via @saveable, save, and load
  • Systematically modifying modules by traversing nested modules
  • Safely handling shared/cyclical references and static arguments through seli.jit
  • Commonly used NN layers and optimizers are included
  • As a small codebase, it is relatively easy to understand and extend

Quick Example

Define new layers by subclassing seli.Module. All modules are PyTrees. Check out the examples for more sophisticated usage.

# add a name to make the module saveable
class Linear(seli.Module, name="example:Linear");
    def __init__(self, dim: int)
        self.dim = dim

        # parameters can be directly initialized
        # or an initialization method can be passed
        self.weight = seli.netParam(init=seli.net.InitNormal("He"))

    def __call__(self, x):
        # the weight gets initialized on the first call
        # by providing the shape, the value is stored
        return x @ self.weight((x.shape[-1], self.dim))

# set the rngs for all submodules at once
# no code for passing rngs around is needed
model = Linear(10).set_rngs(42)
y = model(jnp.ones(8))

A training step can be written as follows, it requires python 3.11 or newer.

optimizer = seli.opt.Adam(1e-3)
loss = seli.opt.MeanSquaredError()

x = jax.numpy.ones(32, 8)
y = jax.numpy.ones(32, 10)

optimizer, model, loss_value = optimizer.minimize(loss, model, y, x)

Models can be serialized and loaded. This process is safe and does not use pickling.

seli.save(model, "model.npz")

# load the model
model = seli.load("model.npz")
assert isinstance(model, Linear)

Installation

You can install from PyPI using pip

pip install seli

See Also

  • Jax Docs: Jax is a library for numerical computing that is designed to be composable and fast.
  • Equinox library: FlareJax is heavily inspired by this awesome library.
  • torch.nn.Module: Many of the principles of mutability are inspired by PyTorch's torch.nn.Module.
  • NNX Docs: NNX is a library for neural networks in flax that also supports mutability.
  • Always feel free to reach out to me via email.

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

seli-0.1.2.tar.gz (49.0 kB view details)

Uploaded Source

Built Distribution

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

seli-0.1.2-py3-none-any.whl (36.8 kB view details)

Uploaded Python 3

File details

Details for the file seli-0.1.2.tar.gz.

File metadata

  • Download URL: seli-0.1.2.tar.gz
  • Upload date:
  • Size: 49.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for seli-0.1.2.tar.gz
Algorithm Hash digest
SHA256 90f5301aadc2393bd1ac2f23b0fb0d1b9ec5b70ec8c2390c1faefa479373c272
MD5 e19b0179ff8bb6187ee6e11a9b424435
BLAKE2b-256 f71ba2b5de815e5951787e1d821a59200cd85433f7f9764d0ced69e076a8d0b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for seli-0.1.2.tar.gz:

Publisher: publish.yml on pwolle/seli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file seli-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: seli-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 36.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for seli-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d390d3f0d5d341dbf5e1ab68aef434b7c2ab6fa43fbf23f336349ed695651a74
MD5 e2048b9f4e8cfdec59d04706e860bd6f
BLAKE2b-256 b34b1ce66f85e91f9dc39bfcf4070bad2618041b9c0f3d809b0b469b4510170b

See more details on using hashes here.

Provenance

The following attestation bundles were made for seli-0.1.2-py3-none-any.whl:

Publisher: publish.yml on pwolle/seli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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