Skip to main content

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

If kerze is published on PyPI, install it with:

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
  ↓
nn
  • 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-0.0.1.tar.gz (54.9 kB view details)

Uploaded Source

Built Distribution

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

kerze-0.0.1-py3-none-any.whl (38.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kerze-0.0.1.tar.gz
  • Upload date:
  • Size: 54.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.4

File hashes

Hashes for kerze-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7125472ae14e190fb80ce567c987c253e35bcc0a496603d3d8f4215df0b1769e
MD5 49d0a1c9fcf828f84f17da4a6a55d06f
BLAKE2b-256 070cac1b82b6bc99a2cc56b504bfd004e7836281b48258bc0422315918bdf868

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kerze-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 38.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.4

File hashes

Hashes for kerze-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7e0900994fbd09bf176a36368ac9464dba984ba3242cfe390e4b3b241d844ab
MD5 c2d64dc0043500213955e2eaeb574da3
BLAKE2b-256 d8f4ead413bf3d4d03e6a3b81d6f50a2299b2bc9ace9795d1c09efe6fe860025

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.1

2 files

1.0.0

2 files

This release

0.0.1 This release

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