Skip to main content

A neural network library for JAX that combines functional init/apply style with a flexible model definition.

Project description

Metoryx

Metoryx is a neural network library for JAX that combines the functional init/apply style with a flexible model definition. It cleanly separates logic (pure functions) from state (parameters) while keeping the workflow intuitive and easy to extend. If you value reusability, testability, and compatibility with the JAX ecosystem, Metoryx is for you.

[!CAUTION] This project is a work in progress, and the API may change.

Features

  • Flexible model definitions: Define models in a Pythonic, PyTorch-like style.
  • Seamless JAX integration: Transform models into pure init/apply functions that work with jax.jit, jax.vmap, and jax.pmap.
  • Easy customization: Implement LoRA, transfer learning, and other techniques with minimal boilerplate; parameters are regular Python objects you can inspect and modify.

Installation

pip install metoryx

Quick Example

Define a model by subclassing mx.Module.

import jax
import jax.numpy as jnp

import metoryx as mx


class MyModel(mx.Module):
    def __init__(self):
        super().__init__()
        self.dense1 = mx.Dense(16, 128)
        self.dense2 = mx.Dense(128, 10)

    def __call__(self, x):
        x = self.dense1(x)
        x = mx.relu(x)
        return self.dense2(x)


model = MyModel()

# Model instance is a Python object that can be manipulated freely.
model.dense2 = mx.Dense(128, 5)  # Replace the last layer
model.dense1.kernel.value = jnp.zeros((16, 128), jnp.float32)  # Set initial weights directly

# Transform the module into JAX-native pure functions.
init, apply = mx.transform(model)

# Create PRNG keys
rng = jax.random.PRNGKey(0)
init_rng, apply_rng = jax.random.split(rng)

# Initialize parameters
variables = init(init_rng)

# Forward pass (with JIT compilation)
x = jnp.zeros((16,))
y, new_variables = jax.jit(apply)(variables, apply_rng, x)

More examples can be found in metoryx/examples.

Future Plans

  • More layers and utilities (e.g., RNNs, attention, parameterized activation functions)
  • Advanced features (e.g., mixed precision)
  • Better documentation and tutorials
  • Expanded examples
  • Expanded test coverage

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

metoryx-0.0.1a0.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

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

metoryx-0.0.1a0-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file metoryx-0.0.1a0.tar.gz.

File metadata

  • Download URL: metoryx-0.0.1a0.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for metoryx-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 78d2079149cdba6d5613bdf0ab94fa7b08667628d31a6ed9fab96bc68bac0a83
MD5 566072067a7748905feac3c8403b778d
BLAKE2b-256 87488c70a91da7393d385d32a2d8df154393e27ca83092e263f5eb55a00699a9

See more details on using hashes here.

File details

Details for the file metoryx-0.0.1a0-py3-none-any.whl.

File metadata

  • Download URL: metoryx-0.0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for metoryx-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 72f469c3c95b68bf9864febde1a4b230517639b32802f1fa448f757ca7d87ad3
MD5 3966b7de1ced048b296530dbf11b466c
BLAKE2b-256 126b2e7599031ea850f4622faca78ed123708b7aacb57dcc35475eac5e11e6cd

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