gradipy: A Lightweight Neural Network Library
gradipy is an evolving project, and it will potentially provide PyTorch-like API for building and training neural networks, there are some features that are actively developed on and plan to support in future releases.
Desired features to add:
- PyTorch like API for most important blocks for training NNs
- Convolutional layers for image processing
- Recurrent layers for sequence data
- Potentially GPU acceleration
Please note that the library is currently in its early stages, and these features are expected in future updates.
Sample Usage
Here's a basic example of using gradipy to create and train a simple neural network for MNIST (please refer to the example usage):
import gradipy.nn as nn
from gradipy import datasets
from gradipy.nn import optim
X_train, y_train, X_val, y_val, X_test, y_test = datasets.MNIST()
# define some utility function here...
class DenseNeuralNetwork:
def __init__(self, input_dim, hidden_dim, output_dim):
self.W1 = nn.init_kaiming_normal(input_dim, hidden_dim, nonlinearity="relu")
self.W2 = nn.init_kaiming_normal(hidden_dim, output_dim, nonlinearity="relu")
def forward(self, X):
logits = X.matmul(self.W1).relu().matmul(self.W2)
return logits
model = DenseNeuralNetwork(input_dim, hidden_dim, output_dim)
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam([model.W1, model.W2], lr=lr)
for epoch in range(epochs + 1):
optimizer.zero_grad()
xb, yb = get_batch()
logits = model.forward(xb)
loss = criterion(logits, yb)
loss.backward()
optimizer.step()
# log the results on each epoch...
In this example, we define a simple feedforward neural network, compile it, and train it on random data. gradipy will provide building blocks like Linear layers, activation functions, loss functions, and optimizers for creating and training neural networks.
Feature Roadmap
Here's a list of features we plan to implement in gradipy, along with their current status:
To-Do
- Backward passes for:
mul(problem with broadcasting),tanh - Add more operations and their gradients
- Batchnorm
- Convolutional layers for image processing
- PyTorch's
nn.Module - More Loss functions (
nn.MSELossandnn.NLLLoss) - Recurrent layers for sequence data
- GPU acceleration (no idea how to do that)
Done
- Basic Tensor wrapper around NumPy
ndarray - Forward and backward passes implemented for:
add,matmul,softmax,relu,sub,log,exp,log softmax,cross entropy - Autograd just like PyTorch's
backwardmethod using topological sort - nn.CrossEntropyLoss function
- Train MNIST with
gradipy - Kaiming, Xavier init (normal + uniform)
- Implemented Adam and added momentum to SGD
Metadata
Release files for gradipy 0.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 | Provenance | Actions |
|---|---|---|---|---|
| gradipy-0.1.0.tar.gz | 7.4 kB | Without provenance | Details for gradipy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gradipy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for gradipy-0.1.0-py3-none-any.whl |
Total release size: 14.8 kB
Release files / gradipy-0.1.0.tar.gz
| Download URL | gradipy-0.1.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e763aac225a285263f6d40184c850cebd3726ad7b3bd481e132a2f7ba2d0160
|
|
BLAKE2b-256 checksum How to use checksums |
bcce1df61c37dc1129db5ef579ddcc25b543132003b6117625fde6ca15e13f66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Release files / gradipy-0.1.0-py3-none-any.whl
| Download URL | gradipy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba14a546e8fe8dc048e8bcd149c707f9f99e41a4aaaca066e6e463a8cfc645ca
|
|
BLAKE2b-256 checksum How to use checksums |
782c26eada0cccc16e3ea73a87d90d78f0ea22c56217e2aeb55b8ce18dea175f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Security for gradipy 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.