Mini deep learning framework
Project description
Kiwigrad
Despite lacking the ability to fly through the skies like PyTorch and TensorFlow, the Kiwigrad is still a formidable bird that is teeming with untapped potential waiting to be uncovered. :wink:
Kiwigrad? yes, it is another version of micrograd that was created just for fun and experimentation.
Install
To install the current release,
pip install kiwigrad
Functionalities
Kiwigrad is a modified version of the micrograd and the minigrad packages with additional features. The main features added to Kiwigrad are:
- Training is faster due to the C implementation of the Value object.
- Tracing functionalities like the original micrograd package were added. An example of this can be seen in the ops notebook.
- Methods for saving and loading the weights of a trained model.
- Support for RNN(1) feedforward neural networks.
Examples
- In the examples folder, you can find examples of models trained using the Kiwigrad library.
- A declaration example of an MLP net using Kiwigrad:
from kiwigrad import MLP, Layer
class PotNet(MLP):
def __init__(self):
layers = [
Layer(nin=2, nout=16, bias=True, activation="relu"),
Layer(nin=16, nout=16, bias=True, activation="relu"),
Layer(nin=16, nout=1, bias=True, activation="linear")
]
super().__init__(layers=layers)
model = PotNet()
from kiwigrad import Value, draw_dot
a = Value(-4.0)
b = Value(2.0)
c = a + b
d = a * b + b**3
c += c + Value(1.)
c += Value(1.) + c + (-a)
d += d * Value(2) + (b + a).relu()
d += Value(3.) * d + (b - a).relu()
e = c - d
f = e**2
g = f / Value(2.0)
g += Value(10.0) / f
print(f'{g.data:.4f}') # prints 24.7041, the outcome of this forward pass
g.backward()
print(f'{a.grad:.4f}') # prints 138.8338, i.e. the numerical value of dg/da
print(f'{b.grad:.4f}') # prints 645.5773, i.e. the numerical value of dg/db
draw_dot(g)
Running test
cd test
pytest .
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
kiwigrad-0.28.tar.gz
(10.4 kB
view details)
Built Distribution
File details
Details for the file kiwigrad-0.28.tar.gz
.
File metadata
- Download URL: kiwigrad-0.28.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe118ec44b0a7f2b3573f8807481a182b7b390a9cc51284e8404523ee60d0332 |
|
MD5 | b8d647525d57e594a485393e5ab0d8ec |
|
BLAKE2b-256 | 70cc26f79c4d09886377fda0ff4a1fd845b8013b168b0c0b9f1eceeb639155c2 |
File details
Details for the file kiwigrad-0.28-cp39-cp39-macosx_10_9_universal2.whl
.
File metadata
- Download URL: kiwigrad-0.28-cp39-cp39-macosx_10_9_universal2.whl
- Upload date:
- Size: 17.5 kB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73cca6c4fcc751bfa0ca7564159818ef62cea3951144be64a57d4a2bf77031fb |
|
MD5 | c946768d6b912b8061274890a8781dcf |
|
BLAKE2b-256 | 5db4c6db648eeace5c080288102f92b765537d719a7ab5a4298457000506bc5c |