Skip to main content

Kerze logo

kerze

A lightweight, PyTorch-like machine learning library built from scratch in Python.

kerze combines a small NumPy-inspired multidimensional array implementation with an automatic differentiation engine and a neural-network API.

The project is designed to make the internals of numerical computing and deep learning easier to understand by keeping the implementation small, explicit, and readable.

⚠️ Warning: kerze is primarily an experimental project, not a replacement for NumPy, PyTorch, or other production-grade numerical computing frameworks and it currently supports CPU execution only. There is no GPU/CUDA support.

Installation

Install with pip

pip install kerze

From Source

git clone https://github.com/ghpratik/kerze.git
cd kerze
pip install -e .

Overview

Kerze is organized into three main layers:

Array
  ↓
Tensor + Autograd
  ↓
neural nets
  • Array — NumPy-like multidimensional array and mathematical operations.
  • Tensor — wraps Array and adds automatic differentiation.
  • nn — PyTorch-like neural-network building blocks.

🚀 Try Kerze

Run a complete XOR neural network example in Google Colab:

Open In Colab

Example:

from kerze import Tensor, nn

model = nn.Sequential(
    nn.Linear(3, 8),
    nn.ReLU(),
    nn.Linear(8, 1),
)

x = Tensor([[1.0, 2.0, 3.0]], requires_grad=True)
y = model(x)

loss = y.mean()
loss.backward()

Features

  • NumPy-inspired multidimensional Array
  • Broadcasting
  • Elementwise arithmetic operations
  • Matrix multiplication
  • Reductions such as sum, mean, and max
  • Reshape, transpose, squeeze, and other shape operations
  • Automatic differentiation
  • Reverse-mode backpropagation
  • Computation graphs
  • Gradient accumulation
  • Gradient broadcasting / unbroadcasting
  • Basic mathematical operations
  • Activation functions
  • Neural-network modules
  • Learnable Parameters
  • Sequential models
  • Linear layers
  • Loss functions
  • Functional neural-network API
  • Parameter initialization
  • Training/evaluation modes
  • PyTorch-like API design

Neural Network API

Kerze provides a small PyTorch-inspired nn API:

nn.Module
nn.Parameter
nn.Linear

nn.ReLU
nn.GELU
nn.Sigmoid
nn.Tanh

nn.MSELoss
nn.NLLLoss
nn.CrossEntropyLoss

nn.Sequential

Functional operations are available through:

from kerze.nn import functional as F

Autograd

Kerze builds a computation graph during tensor operations and traverses it backwards during:

loss.backward()

Each operation defines its own backward rule, allowing gradients to propagate through arithmetic, reductions, activations, matrix multiplication, and other supported operations.

Scope & Limitations

Kerze is intentionally small and educational.

  • CPU only
  • No GPU/CUDA support
  • No optimized C/C++ kernels
  • Limited NumPy compatibility
  • Limited neural-network layers
  • No optimizers yet / limited optimizer support
  • No distributed training
  • No production-scale performance guarantees
  • Some operations support a smaller set of shapes/features than NumPy/PyTorch

The implementation prioritizes clarity and understanding of the underlying mechanics over performance and completeness.

Documentation

Detailed documentation is available in docs/:

Status

Kerze is an experimental/learning project and is actively evolving.

License

Kerze is licensed under the MIT License.

Download files

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

Source Distribution

kerze-1.0.1.tar.gz (58.2 kB view details)

Uploaded Source

Built Distribution

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

kerze-1.0.1-py3-none-any.whl (38.8 kB view details)

Uploaded Python 3

File details

Details for the file kerze-1.0.1.tar.gz.

File metadata

  • Download URL: kerze-1.0.1.tar.gz
  • Upload date:
  • Size: 58.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for kerze-1.0.1.tar.gz
Algorithm Hash digest
SHA256 14e150c23015e5cb956f446ddd62c1609e02737eb45ab7ed1b9724bb9c638679
MD5 cd87096f15290368a11f493e34497e75
BLAKE2b-256 c7bea34bace3a699997683a8fef39e1052973e6d6080418c16b3dfea0921d002

See more details on using hashes here.

Provenance

The following attestation bundles were made for kerze-1.0.1.tar.gz:

Publisher: python-publish.yml on ghpratik/kerze

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

File details

Details for the file kerze-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: kerze-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 38.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for kerze-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b361a5423f5c7b6125a176a91bd4e14bcbf8b04157f0ca8f9b5c1cc00d30be0f
MD5 b23c30dd31e0e20acad74fe54cfd5b24
BLAKE2b-256 ab9b7d8ef96a740626abb33a87ce94cb14946f005e2d7f9303f9c7c07f8a6407

See more details on using hashes here.

Provenance

The following attestation bundles were made for kerze-1.0.1-py3-none-any.whl:

Publisher: python-publish.yml on ghpratik/kerze

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

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page