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.

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.0.tar.gz (58.0 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.0-py3-none-any.whl (38.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kerze-1.0.0.tar.gz
  • Upload date:
  • Size: 58.0 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.0.tar.gz
Algorithm Hash digest
SHA256 c62a9a8e6f6b27024d0bdfc5e08ea9b572f915504fbca7bc48686d42460b2b77
MD5 efcbfccd555f03bfc7a511054b73f0de
BLAKE2b-256 276e8d81fd214dfa9bd784b6581fad2e15748846a759b6f39ab2f2049d799ae5

See more details on using hashes here.

Provenance

The following attestation bundles were made for kerze-1.0.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: kerze-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 38.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 548cebfde3419d4eaa1cc3adeca110eb831e6985150709cec7ceb048e2cd8249
MD5 71e43d8ff7cd05f13a466a935351fdbf
BLAKE2b-256 04274006f876e9f710bcc27dfac6c0b0aae93c290c450bc6a1410fe71f78070c

See more details on using hashes here.

Provenance

The following attestation bundles were made for kerze-1.0.0-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

1.0.1

2 files

This release

1.0.0 This release

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