A minimalistic framework for building neural networks in Python.
Project description
Sorix
sorix: is a library of Artificial Intelligence for beginners.
It provides a NumPy/CuPy-based backend for handling tensors on both CPU and GPU, making it ideal for beginners who want to learn how frameworks like PyTorch work internally.
Install
- With pip
pip install sorix
Or with Poetry:
poetry add sorix
Or with UV
uv add sorix
⚡ Quick Start
Autograd Example
from sorix import tensor
# Create tensors with gradient tracking
x = tensor([2.0], requires_grad=True)
w = tensor([3.0], requires_grad=True)
b = tensor([1.0], requires_grad=True)
# Define a simple function: y = w*x + b
y = w * x + b
# Compute gradients via backpropagation
y.backward()
print("dy/dx:", x.grad) # → should be w = 3
print("dy/dw:", w.grad) # → should be x = 2
print("dy/db:", b.grad) # → should be 1
🔢 Linear Regression Example
import numpy as np
from sorix import tensor
from sorix.nn import Linear, MSELoss
from sorix.optim import SGD
# 🎯 Generate synthetic data (y = 3x + 2 + noise)
X = np.linspace(-1, 1, 100).reshape(-1, 1)
y = 3 * X + 2 + 0.1 * np.random.randn(*X.shape)
# Convert to sorix tensors (CPU, use device="cuda" for GPU)
X_tensor = tensor(X, device="cpu")
y_tensor = tensor(y, device="cpu")
# Define model, loss, and optimizer
features, outputs = 1, 1
model = Linear(features, outputs)
criterion = MSELoss()
optimizer = SGD(model.parameters(), lr=0.1)
# 🏋️ Training loop
for epoch in range(200):
# Forward pass
y_pred = model(X_tensor)
loss = criterion(y_pred, y_tensor)
# Backward pass
optimizer.zero_grad()
loss.backward()
optimizer.step()
# Print progress every 20 epochs
if (epoch + 1) % 20 == 0:
print(f"Epoch [{epoch+1}/200] - Loss: {loss.item():.4f}")
# ✅ Final learned parameters
print("Learned weight:", model.coef_)
print("Learned bias:", model.intercept_)
📖 Documentation & Examples
Explore the interactive examples:
👉 More examples available in the examples folder.
🛠️ Project Status
sorix is under active development 🚧. New features are being added frequently, including:
- More neural network layers.
- Better GPU support.
- Extended autograd functionality.
You can contribute by:
- Reporting issues
- Adding new features
- Improving documentation
- Writing tests
📌 Links
Project details
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 sorix-1.0.0.tar.gz.
File metadata
- Download URL: sorix-1.0.0.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5849d17ea4e73d71adb98e069c236c948bb62798dee84b23a44add14cba432a1
|
|
| MD5 |
cb93ffeff215b7c99cf16240dd11d9f0
|
|
| BLAKE2b-256 |
94b3ac7db2ca2abb2dcb55fd793aef3688c04ad4bab10b8a735572123da4d0f7
|
File details
Details for the file sorix-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sorix-1.0.0-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db7745635d7b9a6c738a0fe2db505cea119f3ba896b3b6c50a2b69509a5a0dee
|
|
| MD5 |
a1c34ceeb9a52124f7e250cc6c0a748f
|
|
| BLAKE2b-256 |
710187cdcf2eaa449742e448ebc4b073050f6bd4bbf404f1f05bd9b15931e5cd
|