A lightweight deep learning framework built from scratch
Project description
NNRT: Neural Network Runtime
NNRT is a lightweight deep learning framework built from scratch in Python.
It is designed to replicate core concepts of modern frameworks like PyTorch, including tensors, autograd, neural networks, and optimizers.
Features
NNRT provides core deep learning components including:
Tensor Core
- Multi dimensional Tensor support
- Autograd (automatic differentiation)
- Basic math operations
- CPU (and optional CUDA support via nnrt.cuda)
Neural Network Layers
- Linear (Fully Connected)
- Conv2D
- MaxPool2D
- BatchNorm1d
- LayerNorm
- Embedding
Activation Functions
- ReLU
- LeakyReLU
- Sigmoid
- Tanh
- GELU
- Softmax
- LogSoftmax
Model Building
- Sequential API
- Module / Parameter system
- ModuleList support
- Dropout
- Flatten layer
Loss Functions
- MSELoss
- CrossEntropyLoss
- NLLLoss
- BCELoss
- BCEWithLogitsLoss
Optimizers
- SGD
- Adam
- RMSProp
Learning Rate Schedulers
- StepLR
- ExponentialLR
- CosineAnnealingLR
Utilities
- Model save / load
- No-grad context manager
Installation
CPU version
pip install nnrt
CUDA Versions
CUDA11.x
pip install nnrt[cuda11x]
CUDA12.x
pip install nnrt[cuda12x]
Quick Example
import nnrt as nn
model = nn.Sequential(
nn.Linear(784, 256),
nn.ReLU(),
nn.Linear(256, 10)
)
loss_fn = nn.CrossEntropyLoss()
optimizer = nn.Adam(model.parameters(), lr=0.001)
x = nn.randn(32, 784)
y = nn.randint(0, 10, (32,))
out = model(x)
loss = loss_fn(out, y)
loss.backward()
optimizer.step()
optimizer.zero_grad()
Goal
NNRT is built for:
- Learning how deep learning frameworks work internally
- Understanding autograd systems
- Experimenting with custom neural network architectures
Disclaimer
This is an educational framework and not optimized for production-scale workloads.
If you find NNRT useful, consider giving it a star on GitHub!
Project details
Release history Release notifications | RSS feed
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 nnrt-26.5.1.tar.gz.
File metadata
- Download URL: nnrt-26.5.1.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db4b8e000aadfd215161e27a2f0b426d0241e54d5b4a11d64014b1da9f7dc12c
|
|
| MD5 |
b5c242dee931ef7cb031d147164d5994
|
|
| BLAKE2b-256 |
7c3e36cdc14be470b713f0b55700733ce2f56fac5735bfeabf078e145b9bdb41
|
File details
Details for the file nnrt-26.5.1-py3-none-any.whl.
File metadata
- Download URL: nnrt-26.5.1-py3-none-any.whl
- Upload date:
- Size: 32.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f403f098b99fbf55e85e71bc4b59e69ecbdfba36b90d06953a03546c0d6ac132
|
|
| MD5 |
b8fdb83d589ea6d225daf47e3413e8b8
|
|
| BLAKE2b-256 |
0b03c9dc3780b65601cc36592c8efe4cf30c3b0d36837826280d4a5f3c862c58
|