A small neural-network framework built from scratch with NumPy.
Project description
Maji
Maji is a small neural-network framework built from scratch with NumPy. It started as a learning project based on the ideas in Neural Networks from Scratch, and this repository is the new home for growing it into a reusable framework.
The current code can build simple feed-forward models for classification, binary classification, and regression. The long-term direction is to grow the core into a clean, well-tested framework that can support deeper model families such as CNNs and transformers, with special attention to performance on Apple silicon.
Install for development
python -m venv .venv
source .venv/bin/activate
python -m pip install -e .
Install from PyPI
After the first release is published:
python -m pip install maji-nn
The PyPI distribution name is maji-nn, and the Python package import remains
maji:
import maji
Quick example
import numpy as np
from maji import (
Adam,
CategoricalAccuracy,
CategoricalCrossEntropyLoss,
DenseLayer,
Model,
ReLU,
Softmax,
)
x = np.array([[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]])
y = np.array([0, 1, 1, 0])
model = Model()
model.add(DenseLayer(2, 8))
model.add(ReLU())
model.add(DenseLayer(8, 2))
model.add(Softmax())
model.set(
loss=CategoricalCrossEntropyLoss(),
optimizer=Adam(learning_rate=0.01),
accuracy=CategoricalAccuracy(),
)
model.finalize()
model.train(x, y, epochs=10, print_every=1)
What is included now
- Dense layers
- Dropout
- ReLU, Softmax, Sigmoid, and Linear activations
- Categorical cross entropy, binary cross entropy, mean squared error, and mean absolute error losses
- SGD, AdaGrad, RMSProp, and Adam optimizers
- Classification and regression accuracy helpers
- A sequential
ModelAPI with training, evaluation, and model/parameter persistence
Verify
python -m unittest discover -s tests -v
Release
Releases publish to PyPI through GitHub Actions and PyPI Trusted Publishing.
The PyPI project is maji-nn; the GitHub workflow is
.github/workflows/publish.yml; the GitHub environment is pypi.
To release:
git tag v0.1.0
git push origin v0.1.0
gh release create v0.1.0 --generate-notes
Roadmap
- Split the current single-file core into focused modules
- Improve numerical stability and API consistency
- Add benchmarks for NumPy and Apple silicon acceleration paths
- Add convolutional layers
- Add transformer building blocks
- Add documentation and example notebooks
License
No license has been selected yet. Choose a license before publishing Maji for broad reuse.
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 maji_nn-0.1.0.tar.gz.
File metadata
- Download URL: maji_nn-0.1.0.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0c10bf11c5ef55982333749e3cbdf6a51fc613e56e6f94a3fac514fcc9b1431
|
|
| MD5 |
63010ee1ff9d008aa3ac8aa01e501aeb
|
|
| BLAKE2b-256 |
3b0b99168283784a4c2773fd90a288e4f853512b01fe6aa7fe968b72b8a9aa93
|
Provenance
The following attestation bundles were made for maji_nn-0.1.0.tar.gz:
Publisher:
publish.yml on mgithinji/maji
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
maji_nn-0.1.0.tar.gz -
Subject digest:
a0c10bf11c5ef55982333749e3cbdf6a51fc613e56e6f94a3fac514fcc9b1431 - Sigstore transparency entry: 1616729232
- Sigstore integration time:
-
Permalink:
mgithinji/maji@a7804f159e3f0aa8484609b377a38f1934d6a0a1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mgithinji
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a7804f159e3f0aa8484609b377a38f1934d6a0a1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file maji_nn-0.1.0-py3-none-any.whl.
File metadata
- Download URL: maji_nn-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1505024b1abef52c23cc96e078119e123939f940eca38b35e387d9c7cf9bc966
|
|
| MD5 |
90bf33269a75cebe89201df246ab3695
|
|
| BLAKE2b-256 |
7cba82c18d774f1ba4d6638deb6ea5b4b3d6ffe0024d446b7e606a16beef0346
|
Provenance
The following attestation bundles were made for maji_nn-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on mgithinji/maji
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
maji_nn-0.1.0-py3-none-any.whl -
Subject digest:
1505024b1abef52c23cc96e078119e123939f940eca38b35e387d9c7cf9bc966 - Sigstore transparency entry: 1616729294
- Sigstore integration time:
-
Permalink:
mgithinji/maji@a7804f159e3f0aa8484609b377a38f1934d6a0a1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mgithinji
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a7804f159e3f0aa8484609b377a38f1934d6a0a1 -
Trigger Event:
release
-
Statement type: