A lightweight neural-network library built on JAX
Project description
JAXFlow
A lightweight neural-network library built on JAX – pure-functional, multi-device-ready, and flexible enough for both research and production.
🚀 Features
Built from scratch with ❤️ and powered by JAX, JAXFlow began as a deep dive into how libraries like Keras and scikit-learn work under the hood—and evolved into a full-featured framework for high-performance deep learning and machine learning.
- Modular Model API
Build networks using
Sequential, subclassedModels, or pure-layer stacks. - Multi-Device Execution
Fully compatible with
jit,vmap,pmap, andpjitvia PyTree-aware design. - Layer Collection
Dense,Conv,BatchNorm,Dropout,Flatten,Embedding, and customLayersubclasses. - Train-Eval Pipelines
model.compile()+fit()for simplicity, or write your own training loop for advanced control. - Optimizers & Schedulers Integrated with Optax, supports SGD, Adam, RMSProp, and more.
- Losses & Metrics MSE, CrossEntropy, F1Score, Precision, Recall, Accuracy, etc. via streaming metric classes.
- Callbacks & Checkpoints EarlyStopping, ModelCheckpoint, LearningRateScheduler, and Orbax-powered save/load.
- Pre-built Models
Includes
ResNet,MLP,Transformer, and composableBlocks. - Lazy Imports
Top-level
jaxflowis fast to import; deep components load on demand.
📦 Installation
pip install jaxflow
Note:
Requires JAX with CPU/GPU/TPU support.
pip install "jax[cuda]>=0.6.0" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.htmlOr simply use:
pip install --upgrade jaxflow[GPU] # for CUDA support pip install --upgrade jaxflow[tpu] # for TPU support
Python ≥3.9 required.
🎉 Quickstart
JAXFlow models can be defined in two main styles:
1. Subclassing Model
import jaxflow as jf
from jaxflow.models import Model
from jaxflow.layers import Conv2D, MaxPooling2D, Dense
from jaxflow.initializers import GlorotUniform, Zeros
class CNN(Model):
def __init__(self, num_classes: int = 10, name: str = "MyCNN"):
super().__init__(name=name)
self.conv1 = Conv2D(filters=32, kernel_size=(3,3), activation=jf.activations.relu, kernel_initializer=GlorotUniform, bias_initializer=Zeros, padding='SAME')
self.pool1 = MaxPooling2D(pool_size=(2,2))
self.conv2 = Conv2D(filters=64, kernel_size=(3,3), activation=jf.activations.relu, kernel_initializer=GlorotUniform, bias_initializer=Zeros, padding='SAME')
self.pool2 = MaxPooling2D(pool_size=(2,2))
self.flatten = jf.layers.GlobalAveragePooling2D()
self.dense1 = Dense(units=64, activation=jf.activations.relu, kernel_initializer=GlorotUniform, bias_initializer=Zeros)
self.outputs = Dense(units=num_classes, activation=jf.activations.softmax, kernel_initializer=GlorotUniform, bias_initializer=Zeros)
def call(self, inputs, training: bool = False):
x = self.conv1(inputs, training=training)
x = self.pool1(x, training=training)
x = self.conv2(x, training=training)
x = self.pool2(x, training=training)
x = self.flatten(x)
x = self.dense1(x, training=training)
return self.outputs(x, training=training)
2. Using the .add() Method (Sequential-style API)
import jaxflow as jf
from jaxflow.models import Model
from jaxflow.layers import Conv2D, MaxPooling2D, Dense
from jaxflow.initializers import GlorotUniform, Zeros
from jaxflow.optimizers import Adam
from jaxflow.losses import SparseCategoricalCrossentropy
model = Model()
model.add(Conv2D(filters=32, kernel_size=(3,3), activation=jf.activations.relu, kernel_initializer=GlorotUniform, bias_initializer=Zeros, padding='SAME'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Conv2D(filters=64, kernel_size=(3,3), activation=jf.activations.relu, kernel_initializer=GlorotUniform, bias_initializer=Zeros, padding='SAME'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(jf.layers.GlobalAveragePooling2D())
model.add(Dense(units=64, activation=jf.activations.relu, kernel_initializer=GlorotUniform, bias_initializer=Zeros))
model.add(Dense(units=10, activation=jf.activations.softmax, kernel_initializer=GlorotUniform, bias_initializer=Zeros))
model.build(input_shape=(None, 28, 28, 1))
model.compile(optimizer=Adam(0.001), loss_fn=SparseCategoricalCrossentropy())
model.fit(x_train, y_train, epochs=5, batch_size=64, validation_split=0.1)
📖 Documentation
Whether you're exploring JAX, need scalable training tools, or just love building things—check it out and let us know what you think!
-
🔗 GitHub: github.com/mthd98/JAXFlow
-
📦 PyPI: pypi.org/project/jaxflow
🛠️ Structure
jaxflow/
├── core/ # Variable management, RNG scopes
├── gradient/ # Autograd and custom gradients
├── activations/ # relu, gelu, swiglu, ...
├── initializers/ # he_normal, glorot_uniform, ...
├── layers/ # Conv2D, Dense, LayerNorm, ...
├── losses/ # mse, cross_entropy, ...
├── optimizers/ # Optax integration
├── callbacks/ # EarlyStopping, Logger, Checkpointing
├── metrics/ # Precision, Recall, Accuracy, ...
├── models/ # Sequential, ResNet, Transformer
└── regularizers/ # Dropout, L2, ...
🚧 Coming Soon
- Transformer layer with attention
- Callback system (EarlyStopping, ModelCheckpoint, etc.)
- Model saving/loading
- Classical ML models (SVM, Logistic Regression, KNN, Random Forest)
📄 License
JAXFlow is distributed under the Apache-2.0 License. See LICENSE for full details.
With JAXFlow, keep your research code clean, fast, and scalable.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 jaxflow-0.1.4.dev0.tar.gz.
File metadata
- Download URL: jaxflow-0.1.4.dev0.tar.gz
- Upload date:
- Size: 55.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e712fe822c844375807b6532d9c7e5111bae544e7758cf2eeb574fd4b113f2a7
|
|
| MD5 |
6796fe753a540a6a82e1631fb8e055c1
|
|
| BLAKE2b-256 |
fbff6460d0d9c66537c4a702782a778ea06482d77caeb3974c308bd16dbd2433
|
Provenance
The following attestation bundles were made for jaxflow-0.1.4.dev0.tar.gz:
Publisher:
python-publish.yml on mthd98/JAXFlow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jaxflow-0.1.4.dev0.tar.gz -
Subject digest:
e712fe822c844375807b6532d9c7e5111bae544e7758cf2eeb574fd4b113f2a7 - Sigstore transparency entry: 219327520
- Sigstore integration time:
-
Permalink:
mthd98/JAXFlow@cef4f4a1785f97270b05e3b5e60c169ada538b40 -
Branch / Tag:
refs/tags/0.1.4.dev0 - Owner: https://github.com/mthd98
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@cef4f4a1785f97270b05e3b5e60c169ada538b40 -
Trigger Event:
release
-
Statement type:
File details
Details for the file jaxflow-0.1.4.dev0-py3-none-any.whl.
File metadata
- Download URL: jaxflow-0.1.4.dev0-py3-none-any.whl
- Upload date:
- Size: 73.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a8bfa596d1d9db7965c0989d70a0b8343ceb39a5d48b3012d282c35b78de782
|
|
| MD5 |
69bd034641bb1a29bb45015cdc9b5744
|
|
| BLAKE2b-256 |
4b6a088bdcc37cb2c1085a50d9bc292e025acefa5867d469d1d98e9134ac2f59
|
Provenance
The following attestation bundles were made for jaxflow-0.1.4.dev0-py3-none-any.whl:
Publisher:
python-publish.yml on mthd98/JAXFlow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jaxflow-0.1.4.dev0-py3-none-any.whl -
Subject digest:
6a8bfa596d1d9db7965c0989d70a0b8343ceb39a5d48b3012d282c35b78de782 - Sigstore transparency entry: 219327521
- Sigstore integration time:
-
Permalink:
mthd98/JAXFlow@cef4f4a1785f97270b05e3b5e60c169ada538b40 -
Branch / Tag:
refs/tags/0.1.4.dev0 - Owner: https://github.com/mthd98
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@cef4f4a1785f97270b05e3b5e60c169ada538b40 -
Trigger Event:
release
-
Statement type: