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.

Metadata

Release files for kerze 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kerze 1.0.1
File Size Uploaded Provenance
kerze-1.0.1.tar.gz 58.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for kerze 1.0.1
File Interpreter ABI Platform
kerze-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 97.0 kB

Release files / kerze-1.0.1.tar.gz

Download URL kerze-1.0.1.tar.gz
Size 58.2 kB
Tags Source
SHA-256 checksum
How to use checksums
14e150c23015e5cb956f446ddd62c1609e02737eb45ab7ed1b9724bb9c638679
BLAKE2b-256 checksum
How to use checksums
c7bea34bace3a699997683a8fef39e1052973e6d6080418c16b3dfea0921d002
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.

Transparency log

Release files / kerze-1.0.1-py3-none-any.whl

Download URL kerze-1.0.1-py3-none-any.whl
Size 38.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b361a5423f5c7b6125a176a91bd4e14bcbf8b04157f0ca8f9b5c1cc00d30be0f
BLAKE2b-256 checksum
How to use checksums
ab9b7d8ef96a740626abb33a87ce94cb14946f005e2d7f9303f9c7c07f8a6407
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.

Transparency log

Security for kerze 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kerze-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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