PyZapo
PyZapo is a lightweight, modular, object-oriented deep learning framework built completely from scratch using only NumPy. It mimics the intuitive style of PyTorch, making it perfect for understanding modern neural network mechanics under the hood.
🚀 Features
- Custom Autograd & Tensor Engine (New in 1.1.0): Supports computational graphs with automated backward passes for seamless gradient tracking via
Tensorand evaluation controls viano_grad. - Object-Oriented Architecture: Build clean pipelines using
Sequentialblocks and customModuleclasses. - Robust Built-in Optimization: Every linear layer comes equipped with an integrated Adam optimizer right out of the box.
- Gradient Saturation Protection: Custom math safety controls (including vector clipping) in activations like
Sigmoidto prevent gradient death. - Advanced Loss Functions: Supports
MSELoss,BCELoss(with automatic stabilization), and full multi-classCrossEntropyLoss(Fused Softmax + CE).
📦 Installation
Install the package directly from PyPI:
pip install pyzapo
🛠️ Quick Start: Multi-Class Digit Classification (0-9)
Here is how easily you can build, train, and test a deep neural network using PyZapo 1.1.0 to classify inputs into 10 different categories (perfectly suited for datasets like MNIST):
import numpy as np
import pyzapo as pz
# 1. Generate synthetic dataset (e.g., 5 flattened 28x28 images)
X = np.random.rand(5, 784)
# One-hot encoded labels for 10 distinct classes (digits 0-9)
y = np.eye(10)[:5]
# 2. Define deep network architecture (Clean OOP Style without .forward())
model = pz.Sequential([
pz.Linear(784, 32),
pz.ReLU(),
pz.Linear(32, 10)
])
criterion = pz.CrossEntropyLoss()
# 3. Training Loop with automated backpropagation and Adam steps
print('Training the model...')
for epoch in range(1501):
logits = model(X) # Clean call syntax
loss = criterion(logits, y) # Fused Softmax + CrossEntropy
loss_grad = criterion.backward()
model.backward(loss_grad)
model.step(lr=0.01)
if epoch % 300 == 0:
print(f'Epoch {epoch:4d} | Loss: {loss:.6f}')
# 4. Inference and Evaluation using no_grad context
with pz.no_grad():
test_logits = model(X)
shift_logits = test_logits - np.max(test_logits, axis=-1, keepdims=True)
probs = np.exp(shift_logits) / np.sum(np.exp(shift_logits), axis=-1, keepdims=True)
predictions = np.argmax(probs, axis=-1)
true_classes = np.argmax(y, axis=-1)
print(f'True Labels: {true_classes.tolist()}')
print(f'Predictions: {predictions.tolist()}')
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
Release files for pyzapo 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyzapo-1.1.0.tar.gz | 5.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyzapo-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.8 kB
Release files / pyzapo-1.1.0.tar.gz
| Download URL | pyzapo-1.1.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b476d935f17f1ff4c4736c7c44aa39915a14b06e80b8b4414d9041190b52bfd3
|
|
BLAKE2b-256 checksum How to use checksums |
b4363f4ded7d8baf9fe64b37cecabac2e509091295f8f8a3402df1db09f3b6eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Release files / pyzapo-1.1.0-py3-none-any.whl
| Download URL | pyzapo-1.1.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a4ea1d8c0a6ed8487936763e9020d1307135f66e303ff85387c29ed5d1e0f4cb
|
|
BLAKE2b-256 checksum How to use checksums |
a9b99190017341dc376df0b8f2d4ce7e9f879f077cd8314f111a91c8b833d21f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|