Skip to main content

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 Model API 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maji_nn-0.1.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

maji_nn-0.1.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

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

Hashes for maji_nn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a0c10bf11c5ef55982333749e3cbdf6a51fc613e56e6f94a3fac514fcc9b1431
MD5 63010ee1ff9d008aa3ac8aa01e501aeb
BLAKE2b-256 3b0b99168283784a4c2773fd90a288e4f853512b01fe6aa7fe968b72b8a9aa93

See more details on using hashes here.

Provenance

The following attestation bundles were made for maji_nn-0.1.0.tar.gz:

Publisher: publish.yml on mgithinji/maji

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

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

Hashes for maji_nn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1505024b1abef52c23cc96e078119e123939f940eca38b35e387d9c7cf9bc966
MD5 90bf33269a75cebe89201df246ab3695
BLAKE2b-256 7cba82c18d774f1ba4d6638deb6ea5b4b3d6ffe0024d446b7e606a16beef0346

See more details on using hashes here.

Provenance

The following attestation bundles were made for maji_nn-0.1.0-py3-none-any.whl:

Publisher: publish.yml on mgithinji/maji

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