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— wrapsArrayand adds automatic differentiation.nn— PyTorch-like neural-network building blocks.
🚀 Try Kerze
Run a complete XOR neural network example in Google 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, andmax - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14e150c23015e5cb956f446ddd62c1609e02737eb45ab7ed1b9724bb9c638679
|
|
| MD5 |
cd87096f15290368a11f493e34497e75
|
|
| BLAKE2b-256 |
c7bea34bace3a699997683a8fef39e1052973e6d6080418c16b3dfea0921d002
|
Provenance
The following attestation bundles were made for kerze-1.0.1.tar.gz:
Publisher:
python-publish.yml on ghpratik/kerze
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kerze-1.0.1.tar.gz -
Subject digest:
14e150c23015e5cb956f446ddd62c1609e02737eb45ab7ed1b9724bb9c638679 - Sigstore transparency entry: 2499937947
- Sigstore integration time:
-
Permalink:
ghpratik/kerze@d37aa78d1201f7fe2afaf8db835c0c9a93045b18 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/ghpratik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d37aa78d1201f7fe2afaf8db835c0c9a93045b18 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b361a5423f5c7b6125a176a91bd4e14bcbf8b04157f0ca8f9b5c1cc00d30be0f
|
|
| MD5 |
b23c30dd31e0e20acad74fe54cfd5b24
|
|
| BLAKE2b-256 |
ab9b7d8ef96a740626abb33a87ce94cb14946f005e2d7f9303f9c7c07f8a6407
|
Provenance
The following attestation bundles were made for kerze-1.0.1-py3-none-any.whl:
Publisher:
python-publish.yml on ghpratik/kerze
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kerze-1.0.1-py3-none-any.whl -
Subject digest:
b361a5423f5c7b6125a176a91bd4e14bcbf8b04157f0ca8f9b5c1cc00d30be0f - Sigstore transparency entry: 2499937950
- Sigstore integration time:
-
Permalink:
ghpratik/kerze@d37aa78d1201f7fe2afaf8db835c0c9a93045b18 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/ghpratik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d37aa78d1201f7fe2afaf8db835c0c9a93045b18 -
Trigger Event:
release
-
Statement type: